iio: Check whether getting float values fails

If we cannot parse the contents of sysfs attribute that's supposed to
contain floats, throw an error.
This commit is contained in:
Bastien Nocera
2019-05-13 13:46:50 +02:00
committed by hadess
parent f521ed1d87
commit ec0d992c18

View File

@@ -228,7 +228,10 @@ iioutils_get_param_float (float *output,
sysfsfp = fopen (filename, "r"); sysfsfp = fopen (filename, "r");
if (sysfsfp) { if (sysfsfp) {
fscanf (sysfsfp, "%f", output); if (fscanf (sysfsfp, "%f", output) != 1) {
g_debug ("Failed to read float from %s", filename);
ret = -EINVAL;
}
fclose (sysfsfp); fclose (sysfsfp);
} else { } else {
ret = -errno; ret = -errno;