diff options
author | Guido MartÃnez <guido@vanguardiasur.com.ar> | 2014-09-10 11:56:40 -0300 |
---|---|---|
committer | Brian Norris <computersforpeace@gmail.com> | 2014-09-15 10:11:02 -0700 |
commit | 51b71fb46a069fa137c7a02769d60561e178ba15 (patch) | |
tree | bd16987dc67bb91cf46a79466bff623108b0577c /lib/libmtd.c | |
parent | ebf0d3d85910f485ebb64b3df2a6e2042a75c807 (diff) |
libmtd: fix mtd_dev_present return value on legacy systems
On legacy systems, if "/proc/mtd" doesn't exist or gives a read error,
mtd_dev_present returns -1 (since it calls legacy_dev_present), contrary
to what's specified in the header file.
This causes checks like
if (mtd_dev_present(n)) {
...
}
to give false positives. Fix this by comparing the return value to 1.
Signed-off-by: Guido MartÃnez <guido@vanguardiasur.com.ar>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Diffstat (limited to 'lib/libmtd.c')
-rw-r--r-- | lib/libmtd.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/libmtd.c b/lib/libmtd.c index 2089373..aff4c8b 100644 --- a/lib/libmtd.c +++ b/lib/libmtd.c @@ -647,9 +647,9 @@ int mtd_dev_present(libmtd_t desc, int mtd_num) { struct stat st; struct libmtd *lib = (struct libmtd *)desc; - if (!lib->sysfs_supported) - return legacy_dev_present(mtd_num); - else { + if (!lib->sysfs_supported) { + return legacy_dev_present(mtd_num) == 1; + } else { char file[strlen(lib->mtd) + 10]; sprintf(file, lib->mtd, mtd_num); |