Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dc8b5d6e authored by Hartmut Knaack's avatar Hartmut Knaack Committed by Jonathan Cameron
Browse files

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: default avatarHartmut Knaack <knaack.h@gmx.de>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 8e926134
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -144,6 +144,10 @@ int iioutils_get_type(unsigned *is_signed,
				ret = -errno;
				ret = -errno;
				printf("failed to pass scan type description\n");
				printf("failed to pass scan type description\n");
				goto error_close_sysfsfp;
				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');
			*be = (endianchar == 'b');
			*bytes = padint / 8;
			*bytes = padint / 8;