summaryrefslogtreecommitdiff
path: root/trafgen.c
diff options
context:
space:
mode:
authorVadim Kochan <vadim4j@gmail.com>2016-01-14 01:22:40 +0200
committerTobias Klauser <tklauser@distanz.ch>2016-01-14 11:55:39 +0100
commit6f6a60c2aa03796bd9abd512a5aa0eeb48f3d09e (patch)
treea6a96c8229e2e74e87739b96550051d81565140c /trafgen.c
parent06a08d866094dda92caf33504c748621a2fef0d3 (diff)
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 <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'trafgen.c')
-rw-r--r--trafgen.c11
1 files 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;