From: Hartmut Knaack Date: Sun, 31 May 2015 12:40:03 +0000 (+0200) Subject: tools:iio:generic_buffer: catch errors for arguments conversion X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=c8ce9903cba202936999c2c9463fbb370ee145ba;p=openwrt%2Fstaging%2Fblogic.git tools:iio:generic_buffer: catch errors for arguments conversion Add handler to catch errors on conversion of numerical arguments. Signed-off-by: Hartmut Knaack Signed-off-by: Jonathan Cameron --- diff --git a/tools/iio/generic_buffer.c b/tools/iio/generic_buffer.c index eb89bc2ca5d0..93ac93f74549 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;