examples/qos_sched: fix core mask overflow
authorMegha Ajmera <megha.ajmera@intel.com>
Wed, 23 Feb 2022 17:36:30 +0000 (17:36 +0000)
committerThomas Monjalon <thomas@monjalon.net>
Fri, 25 Feb 2022 09:39:26 +0000 (10:39 +0100)
Masking of core mask was incorrect. Instead of using 1U for shifting, it
should be using 1LU as the result is assigned to uint64.

CID 375859: Potentially overflowing expression "1U << app_main_core" with
type "unsigned int" (32 bits, unsigned) is evaluated using 32-bit
arithmetic, and then used in a context that expects an expression of
type "uint64_t" (64 bits, unsigned).

Coverity issue: 375859
Fixes: de3cfa2c9823 ("sched: initial import")
Cc: stable@dpdk.org
Signed-off-by: Megha Ajmera <megha.ajmera@intel.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
examples/qos_sched/args.c

index 10ca7be..b295949 100644 (file)
@@ -427,13 +427,13 @@ app_parse_args(int argc, char **argv)
 
        /* check main core index validity */
        for (i = 0; i <= app_main_core; i++) {
-               if (app_used_core_mask & (1u << app_main_core)) {
+               if (app_used_core_mask & RTE_BIT64(app_main_core)) {
                        RTE_LOG(ERR, APP, "Main core index is not configured properly\n");
                        app_usage(prgname);
                        return -1;
                }
        }
-       app_used_core_mask |= 1u << app_main_core;
+       app_used_core_mask |= RTE_BIT64(app_main_core);
 
        if ((app_used_core_mask != app_eal_core_mask()) ||
                        (app_main_core != rte_get_main_lcore())) {