2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-30 13:58:14 +00:00

dpif-netdev: Remove undefined integer division.

Clang analyzer will complain about floating point operations conducted
with integer types as rounding is undefined. In pmd_info_show_rxq() a
percentage was calculated inside uint64 integers instead of a floating
pointer variable for a user visible message. This issue can be resolved
simply by casting to double while dividing.

Acked-by: Simon Horman <horms@ovn.org>
Signed-off-by: Mike Pattrick <mkp@redhat.com>
Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
This commit is contained in:
Mike Pattrick
2024-09-09 00:54:59 -04:00
committed by Eelco Chaudron
parent e48ba271f4
commit a67db28fd9

View File

@@ -942,9 +942,9 @@ pmd_info_show_rxq(struct ds *reply, struct dp_netdev_pmd_thread *pmd,
? "(enabled) " : "(disabled)"); ? "(enabled) " : "(disabled)");
ds_put_format(reply, " pmd usage: "); ds_put_format(reply, " pmd usage: ");
if (total_pmd_cycles) { if (total_pmd_cycles) {
ds_put_format(reply, "%2"PRIu64"", ds_put_format(reply, "%2.0f %%",
rxq_proc_cycles * 100 / total_pmd_cycles); (double) (rxq_proc_cycles * 100) /
ds_put_cstr(reply, " %"); total_pmd_cycles);
} else { } else {
ds_put_format(reply, "%s", "NOT AVAIL"); ds_put_format(reply, "%s", "NOT AVAIL");
} }
@@ -959,8 +959,10 @@ pmd_info_show_rxq(struct ds *reply, struct dp_netdev_pmd_thread *pmd,
if (total_rxq_proc_cycles < busy_pmd_cycles) { if (total_rxq_proc_cycles < busy_pmd_cycles) {
overhead_cycles = busy_pmd_cycles - total_rxq_proc_cycles; overhead_cycles = busy_pmd_cycles - total_rxq_proc_cycles;
} }
ds_put_format(reply, "%2"PRIu64" %%",
overhead_cycles * 100 / total_pmd_cycles); ds_put_format(reply, "%2.0f %%",
(double) (overhead_cycles * 100) /
total_pmd_cycles);
} else { } else {
ds_put_cstr(reply, "NOT AVAIL"); ds_put_cstr(reply, "NOT AVAIL");
} }