app/fib: fix division by zero
This patch fixes the division by 0, which occurs if the number of
routes is less than 10.
Can be triggered by passing -n argument with value < 10:
./dpdk-test-fib -- -n 9
...
Floating point exception (core dumped)
Fixes: 103809d032
("app/test-fib: add test application for FIB")
Cc: stable@dpdk.org
Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
Acked-by: Kevin Traynor <ktraynor@redhat.com>
This commit is contained in:
parent
5f69ebbd85
commit
a01070dac9
@ -711,6 +711,10 @@ parse_opts(int argc, char **argv)
|
|||||||
print_usage();
|
print_usage();
|
||||||
rte_exit(-EINVAL, "Invalid option -n\n");
|
rte_exit(-EINVAL, "Invalid option -n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.nb_routes < config.print_fract)
|
||||||
|
config.print_fract = config.nb_routes;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
distrib_string = optarg;
|
distrib_string = optarg;
|
||||||
@ -1242,6 +1246,10 @@ main(int argc, char **argv)
|
|||||||
config.nb_routes = 0;
|
config.nb_routes = 0;
|
||||||
while (fgets(line, sizeof(line), fr) != NULL)
|
while (fgets(line, sizeof(line), fr) != NULL)
|
||||||
config.nb_routes++;
|
config.nb_routes++;
|
||||||
|
|
||||||
|
if (config.nb_routes < config.print_fract)
|
||||||
|
config.print_fract = config.nb_routes;
|
||||||
|
|
||||||
rewind(fr);
|
rewind(fr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user