From 58c28d1778bd72fbe967d59c1650ec14773ddaf7 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Fri, 2 Dec 2022 07:05:25 +0100 Subject: [PATCH] dpdk: fix cppcheck warnings src/runmode-dpdk.c:202:11: warning: Size of pointer 'argv' used instead of size of its data. This is likely to lead to a buffer overflow. You probably intend to write 'sizeof(*argv)'. [pointerSize] args->argv = SCCalloc(capacity, sizeof(args->argv)); ^ src/runmode-dpdk.c:777:23: error: Shifting 32-bit value by 63 bits is undefined behaviour [shiftTooManyBits] if (bits & (1 << i)) ^ src/runmode-dpdk.c:776:23: note: Assuming that condition 'i<64' is not redundant for (int i = 0; i < 64; i++) { ^ src/runmode-dpdk.c:777:23: note: Shift if (bits & (1 << i)) ^ --- src/runmode-dpdk.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/runmode-dpdk.c b/src/runmode-dpdk.c index acb9258404..1b522628b6 100644 --- a/src/runmode-dpdk.c +++ b/src/runmode-dpdk.c @@ -199,7 +199,7 @@ static char *AllocAndSetOption(const char *arg) static void ArgumentsInit(struct Arguments *args, unsigned capacity) { SCEnter(); - args->argv = SCCalloc(capacity, sizeof(args->argv)); + args->argv = SCCalloc(capacity, sizeof(ptrdiff_t)); // alloc array of pointers if (args->argv == NULL) FatalError(SC_ERR_MEM_ALLOC, "Could not allocate memory for Arguments structure"); @@ -790,8 +790,8 @@ static void DeviceSetPMDSpecificRSS(struct rte_eth_rss_conf *rss_conf, const cha // Returns -1 if no bit is set static int GetFirstSetBitPosition(uint64_t bits) { - for (int i = 0; i < 64; i++) { - if (bits & (1 << i)) + for (uint64_t i = 0; i < 64; i++) { + if (bits & BIT_U64(i)) return i; } return -1; -- 2.47.2