summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorHartmut Knaack <knaack.h@gmx.de>2015-05-31 14:39:59 +0200
committerJonathan Cameron <jic23@kernel.org>2015-05-31 17:42:34 +0100
commitdc8b5d6e633f8e54f70594d0be87aaf401ea0559 (patch)
treef5e63a71ac3522b744c32ae292fe7bbb5563e240 /tools
parent8e926134ef15267f65ddfc7389c8078234610295 (diff)
downloadop-kernel-dev-dc8b5d6e633f8e54f70594d0be87aaf401ea0559.zip
op-kernel-dev-dc8b5d6e633f8e54f70594d0be87aaf401ea0559.tar.gz
tools:iio:iio_utils: check amount of matches
fscanf() usually returns the number of input items successfully matched and assigned, which can be fewer than provided (or even zero). Add a check in iioutils_get_type() to make sure all items are matched. Signed-off-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/iio/iio_utils.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/tools/iio/iio_utils.c b/tools/iio/iio_utils.c
index f12bc2e..c5b4136 100644
--- a/tools/iio/iio_utils.c
+++ b/tools/iio/iio_utils.c
@@ -144,6 +144,10 @@ int iioutils_get_type(unsigned *is_signed,
ret = -errno;
printf("failed to pass scan type description\n");
goto error_close_sysfsfp;
+ } else if (ret != 5) {
+ ret = -EIO;
+ printf("scan type description didn't match\n");
+ goto error_close_sysfsfp;
}
*be = (endianchar == 'b');
*bytes = padint / 8;
OpenPOWER on IntegriCloud