Library functions never reset errno to zero, so if you want
to use its value to check for errors then you must set it to zero
before calling the library function (in this case readdir).
Signed-off-by: Adrian Hunter <ext-adrian.hunter@nokia.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
}
info->lowest_dev_num = INT_MAX;
- while ((dirent = readdir(sysfs_ubi))) {
+ while (1) {
int dev_num, ret;
+ errno = 0;
+ dirent = readdir(sysfs_ubi);
+ if (!dirent)
+ break;
/*
* Make sure this direntry is a directory and not a symlink -
* Linux puts symlinks to UBI volumes on this UBI device to the
return -1;
info->lowest_vol_num = INT_MAX;
- while ((dirent = readdir(sysfs_ubi))) {
+
+ while (1) {
int vol_id, ret, devno;
+ errno = 0;
+ dirent = readdir(sysfs_ubi);
+ if (!dirent)
+ break;
ret = sscanf(dirent->d_name, UBI_VOL_NAME_PATT, &devno, &vol_id);
if (ret == 2 && devno == dev_num) {
info->vol_count += 1;