iio.c: Closedir correctly and return error if we fail to read from the device dir
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
@@ -599,6 +599,8 @@ mraa_iio_update_channels(mraa_iio_context dev)
|
|||||||
if (read(fd, readbuf, 2 * sizeof(char)) != 2) {
|
if (read(fd, readbuf, 2 * sizeof(char)) != 2) {
|
||||||
syslog(LOG_ERR, "iio: Failed to read a sensible value from sysfs");
|
syslog(LOG_ERR, "iio: Failed to read a sensible value from sysfs");
|
||||||
free(str);
|
free(str);
|
||||||
|
close(fd);
|
||||||
|
closedir(dir);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
chan->enabled = (int) strtol(readbuf, NULL, 10);
|
chan->enabled = (int) strtol(readbuf, NULL, 10);
|
||||||
@@ -617,8 +619,11 @@ mraa_iio_update_channels(mraa_iio_context dev)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
closedir(dir);
|
||||||
|
return MRAA_SUCCESS;
|
||||||
}
|
}
|
||||||
return MRAA_SUCCESS;
|
|
||||||
|
return MRAA_ERROR_INVALID_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
mraa_result_t
|
mraa_result_t
|
||||||
|
|||||||
Reference in New Issue
Block a user