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 <[email protected]> --- 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; -- 2.6.3 -- You received this message because you are subscribed to the Google Groups "netsniff-ng" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
