diff options
author | Heena Sirwani <heenasirwani@gmail.com> | 2014-10-06 11:34:43 (GMT) |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-10-20 02:29:08 (GMT) |
commit | d0e68ce1999e34a29d6b71ced4088d0f916878d4 (patch) | |
tree | 464a8732213df23fe6140bfe5bf1575cbc846ebf /drivers/staging/iio/Documentation | |
parent | edead9b1f9fa1e28e493ccaa831d0ac7aa0de74b (diff) | |
download | linux-d0e68ce1999e34a29d6b71ced4088d0f916878d4.tar.xz |
Staging: iio: Documentation: Added check for sscanf return value.
The following patch fixes the following checkpatch.pl warning by adding
a check for sscanf return value.
WARNING: unchecked sscanf return value.
Signed-off-by: Heena Sirwani <heenasirwani@gmail.com>
Acked-by: Daniel Baluta <daniel.baluta@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/iio/Documentation')
-rw-r--r-- | drivers/staging/iio/Documentation/lsiio.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/staging/iio/Documentation/lsiio.c b/drivers/staging/iio/Documentation/lsiio.c index 3b436f1..98a0de0 100644 --- a/drivers/staging/iio/Documentation/lsiio.c +++ b/drivers/staging/iio/Documentation/lsiio.c @@ -63,9 +63,12 @@ static int dump_one_device(const char *dev_dir_name) { char name[IIO_MAX_NAME_LENGTH]; int dev_idx; + int retval; - sscanf(dev_dir_name + strlen(iio_dir) + strlen(type_device), + retval = sscanf(dev_dir_name + strlen(iio_dir) + strlen(type_device), "%i", &dev_idx); + if (retval != 1) + return -EINVAL; read_sysfs_string("name", dev_dir_name, name); printf("Device %03d: %s\n", dev_idx, name); @@ -78,9 +81,12 @@ static int dump_one_trigger(const char *dev_dir_name) { char name[IIO_MAX_NAME_LENGTH]; int dev_idx; + int retval; - sscanf(dev_dir_name + strlen(iio_dir) + strlen(type_trigger), + retval = sscanf(dev_dir_name + strlen(iio_dir) + strlen(type_trigger), "%i", &dev_idx); + if (retval != 1) + return -EINVAL; read_sysfs_string("name", dev_dir_name, name); printf("Trigger %03d: %s\n", dev_idx, name); return 0; |