From: Heena Sirwani Date: Mon, 6 Oct 2014 11:34:43 +0000 (+0530) Subject: Staging: iio: Documentation: Added check for sscanf return value. X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=d0e68ce1999e34a29d6b71ced4088d0f916878d4;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git 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 Acked-by: Daniel Baluta Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/iio/Documentation/lsiio.c b/drivers/staging/iio/Documentation/lsiio.c index 3b436f13b872..98a0de098130 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;