[PATCH 13/32] tools:iio:iio_utils: check amount of matches

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxx>
---
 tools/iio/iio_utils.c | 4 ++++
 1 file changed, 4 insertions(+)

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;
-- 
2.3.6

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux