tools:iio:generic_buffer: catch errors for arguments conversion
authorHartmut Knaack <knaack.h@gmx.de>
Sun, 31 May 2015 12:40:03 +0000 (14:40 +0200)
committerJonathan Cameron <jic23@kernel.org>
Sun, 31 May 2015 18:22:57 +0000 (19:22 +0100)
Add handler to catch errors on conversion of numerical arguments.

Signed-off-by: Hartmut Knaack <knaack.h@gmx.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
tools/iio/generic_buffer.c

index eb89bc2ca5d0ada3b6558abb355770a5f01f7f44..93ac93f745497a12eb8239b9563e96f4fae175fd 100644 (file)
@@ -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;