[PATCH 17/32] tools:iio:generic_buffer: catch errors for arguments conversion

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

 



Add handler to catch errors on conversion of numerical arguments.

Signed-off-by: Hartmut Knaack <knaack.h@xxxxxx>
---
 tools/iio/generic_buffer.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tools/iio/generic_buffer.c b/tools/iio/generic_buffer.c
index 9164b27..934b4c9 100644
--- a/tools/iio/generic_buffer.c
+++ b/tools/iio/generic_buffer.c
@@ -206,13 +206,22 @@ int main(int argc, char **argv)
 			noevents = 1;
 			break;
 		case 'c':
+			errno = 0;
 			num_loops = strtoul(optarg, &dummy, 10);
+			if (errno)
+				return -errno;
 			break;
 		case 'w':
+			errno = 0;
 			timedelay = strtoul(optarg, &dummy, 10);
+			if (errno)
+				return -errno;
 			break;
 		case 'l':
+			errno = 0;
 			buf_len = strtoul(optarg, &dummy, 10);
+			if (errno)
+				return -errno;
 			break;
 		case 'g':
 			notrigger = 1;
-- 
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