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:
@@ -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;
|
||||||
|
Reference in New Issue
Block a user