examples/l3fwd-power: fix metrics divisions
authorDavid Hunt <david.hunt@intel.com>
Wed, 10 Jul 2019 15:26:20 +0000 (16:26 +0100)
committerThomas Monjalon <thomas@monjalon.net>
Wed, 10 Jul 2019 22:00:46 +0000 (00:00 +0200)
commit018faf21d670e06d51beb52e1c3c12192a762339
tree083ac57938953ce0de26d5833b921e6e7f2b8a7a
parent221e7026d521c97c58fcee867f003e414dba2eea
examples/l3fwd-power: fix metrics divisions

6 issues caught by Coverity 343465
* Possible divide by zero on 3 lines
* Convert to float then back to int, losing precision on 3 lines

This patch modifies the code so that it only assigns calculated
values if the divisor is > 0, otherwise sets metrics to zero.
Also removes the un-needed round() function.

Coverity issue: 343465
Fixes: 609e79841fcf ("examples/l3fwd-power: add telemetry mode")

Signed-off-by: David Hunt <david.hunt@intel.com>
examples/l3fwd-power/main.c