app/testpmd: fix unintentional integer overflow
authorTiwei Bie <tiwei.bie@intel.com>
Wed, 24 Apr 2019 02:29:31 +0000 (10:29 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 3 May 2019 16:45:23 +0000 (18:45 +0200)
Fix the potential overflow in expression 1 << begin by using 1ULL.

Coverity issue: 279437, 279445
Fixes: c73a9071877a ("app/testpmd: add commands to test new offload API")
Cc: stable@dpdk.org
Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
app/test-pmd/cmdline.c

index 147a617..f45ef8a 100644 (file)
@@ -17833,7 +17833,7 @@ print_rx_offloads(uint64_t offloads)
        begin = __builtin_ctzll(offloads);
        end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
 
-       single_offload = 1 << begin;
+       single_offload = 1ULL << begin;
        for (bit = begin; bit < end; bit++) {
                if (offloads & single_offload)
                        printf(" %s",
@@ -18227,7 +18227,7 @@ print_tx_offloads(uint64_t offloads)
        begin = __builtin_ctzll(offloads);
        end = sizeof(offloads) * CHAR_BIT - __builtin_clzll(offloads);
 
-       single_offload = 1 << begin;
+       single_offload = 1ULL << begin;
        for (bit = begin; bit < end; bit++) {
                if (offloads & single_offload)
                        printf(" %s",