From 6f6a60c2aa03796bd9abd512a5aa0eeb48f3d09e Mon Sep 17 00:00:00 2001 From: Vadim Kochan Date: Thu, 14 Jan 2016 01:22:40 +0200 Subject: trafgen: Simplify 'gap' option unit parsing It is not needed to parse each character to find unit name in the option string but just let to do it via strtoul providing the pointer which will keep non numeric value. Signed-off-by: Vadim Kochan Signed-off-by: Tobias Klauser --- trafgen.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/trafgen.c b/trafgen.c index eec34ea..36694d2 100644 --- a/trafgen.c +++ b/trafgen.c @@ -1087,14 +1087,9 @@ int main(int argc, char **argv) ctx.num = orig_num; break; case 't': - ptr = optarg; - gap = strtoul(optarg, NULL, 0); - - for (j = i = strlen(optarg); i > 0; --i) { - if (!isdigit(optarg[j - i])) - break; - ptr++; - } + gap = strtoul(optarg, &ptr, 0); + if (!gap && optarg == ptr) + panic("Invalid gap param\n"); if (!strncmp(ptr, "ns", strlen("ns"))) { delay.tv_sec = gap / 1000000000; -- cgit v1.2.3-54-g00ecf