]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
dpdk: fix scan-build warnings
authorVictor Julien <vjulien@oisf.net>
Mon, 24 Apr 2023 19:39:45 +0000 (21:39 +0200)
committerVictor Julien <vjulien@oisf.net>
Mon, 24 Apr 2023 19:39:48 +0000 (21:39 +0200)
runmode-dpdk.c:204:18: warning: Result of 'calloc' is converted to a pointer of type 'char *', which is incompatible with sizeof operand type 'ptrdiff_t' [unix.MallocSizeof]
    args->argv = SCCalloc(capacity, sizeof(ptrdiff_t)); // alloc array of pointers
                 ^~~~~~~~           ~~~~~~~~~~~~~~~~~
./util-mem.h:36:18: note: expanded from macro 'SCCalloc'
 #define SCCalloc calloc
                  ^~~~~~
runmode-dpdk.c:278:16: warning: Result of 'malloc' is converted to a pointer of type 'char *', which is incompatible with sizeof operand type 'char **' [unix.MallocSizeof]
    eal_argv = SCMalloc(args.argc * sizeof(args.argv));
               ^~~~~~~~             ~~~~~~~~~~~~~~~~~
./util-mem.h:35:18: note: expanded from macro 'SCMalloc'
 #define SCMalloc malloc
                  ^~~~~~
2 warnings generated.

src/runmode-dpdk.c

index 55cac70a5f5df98dfa21272fb2409aeb55d17de7..2be947b8bb0bf27b2b5db0f7f8d6725b16ebc41a 100644 (file)
@@ -201,7 +201,7 @@ static char *AllocAndSetOption(const char *arg)
 static void ArgumentsInit(struct Arguments *args, unsigned capacity)
 {
     SCEnter();
-    args->argv = SCCalloc(capacity, sizeof(ptrdiff_t)); // alloc array of pointers
+    args->argv = SCCalloc(capacity, sizeof(*args->argv)); // alloc array of pointers
     if (args->argv == NULL)
         FatalError("Could not allocate memory for Arguments structure");
 
@@ -275,7 +275,7 @@ static void InitEal(void)
     }
 
     // creating a shallow copy for cleanup because rte_eal_init changes array contents
-    eal_argv = SCMalloc(args.argc * sizeof(args.argv));
+    eal_argv = SCCalloc(args.argc, sizeof(*args.argv));
     if (eal_argv == NULL) {
         FatalError("Failed to allocate memory for the array of DPDK EAL arguments");
     }