From: David Oberhollenzer Date: Wed, 12 Sep 2018 07:40:34 +0000 (+0200) Subject: libmtd: don't print an error message for devices without ecc support X-Git-Tag: v2.1.0~53 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=a63a209d8ee8f21722a3b07d01d904bca5dbbc31;p=mtd-utils.git libmtd: don't print an error message for devices without ecc support The libmtd library tries to obtain the available OOB size via the sysfs with a fallback to the ECCGETLAYOUT ioctl. For some devices (e.g. plat-ram), the fallback path is always taken and prints an error message to stderr since the ioctl fails. This patch fixes the fallback path by suppressing the error message if errno is set to EOPNOTSUPP (i.e. the device simply doesn't support that). Fixes: a10353584f93 ("libmtd: Add support to access OOB available size") Reported-by: Chris Packham Reviewed-by: Xiaolei Li Tested-by: Chris Packham Signed-off-by: David Oberhollenzer --- diff --git a/lib/libmtd_legacy.c b/lib/libmtd_legacy.c index 97fef04..2b7f65f 100644 --- a/lib/libmtd_legacy.c +++ b/lib/libmtd_legacy.c @@ -235,6 +235,8 @@ int legacy_get_mtd_oobavail(const char *node) ret = ioctl(fd, ECCGETLAYOUT, &usrlay); if (ret < 0) { + if (errno == EOPNOTSUPP) + goto out_close; sys_errmsg("ECCGETLAYOUT ioctl request failed"); goto out_close; }