]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
dpdk: fix cppcheck warnings
authorVictor Julien <vjulien@oisf.net>
Fri, 2 Dec 2022 06:05:25 +0000 (07:05 +0100)
committerVictor Julien <vjulien@oisf.net>
Wed, 14 Dec 2022 19:04:40 +0000 (20:04 +0100)
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

index acb9258404a16d154bf73d59494476e0076b4432..1b522628b6f18a586d939d3ca290b1873cff8a51 100644 (file)
@@ -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;