Fix a Coverity INTEGER_OVERFLOW warning in dpctl_dump_flows(). The PMD ID is stored as a uint32_t, where UINT32_MAX is used as a sentinel value. Avoid assigning it directly to an int, which may trigger an implementation-defined conversion and cause Coverity to report an INTEGER_OVERFLOW warning.
Keep the variable type consistent with the original data or perform an explicit validity check before conversion to eliminate the warning while preserving the existing behavior. Signed-off-by: Fei Wang <[email protected]> --- lib/dpctl.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/dpctl.c b/lib/dpctl.c index 752168b5a..81e275062 100644 --- a/lib/dpctl.c +++ b/lib/dpctl.c @@ -1044,7 +1044,7 @@ dpctl_dump_flows(int argc, const char *argv[], struct dpctl_params *dpctl_p) struct dpif_flow_dump_thread *flow_dump_thread; struct dpif_flow_dump *flow_dump; struct dpif_flow f; - int pmd_id = PMD_ID_NULL; + unsigned pmd_id = PMD_ID_NULL; bool pmd_id_filter = false; int lastargc = 0; int error; @@ -1063,12 +1063,13 @@ dpctl_dump_flows(int argc, const char *argv[], struct dpctl_params *dpctl_p) } types_list = xstrdup(argv[--argc] + 5); } else if (!strncmp(argv[argc - 1], "pmd=", 4)) { - if (!ovs_scan(argv[--argc], "pmd=%d", &pmd_id)) { + int pmd_id_int; + if (!ovs_scan(argv[--argc], "pmd=%d", &pmd_id_int)) { error = EINVAL; goto out_free; } - if (pmd_id == -1) { + if (pmd_id_int == -1) { pmd_id = NON_PMD_CORE_ID; } pmd_id_filter = true; -- 2.55.0.windows.2 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
