From: Victor Julien Date: Mon, 24 Apr 2023 19:39:45 +0000 (+0200) Subject: dpdk: fix scan-build warnings X-Git-Tag: suricata-7.0.0-rc2~341 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ea67a2edd28fa66403101a554d5bb7df9eae712c;p=thirdparty%2Fsuricata.git dpdk: fix scan-build warnings 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. --- diff --git a/src/runmode-dpdk.c b/src/runmode-dpdk.c index 55cac70a5f..2be947b8bb 100644 --- a/src/runmode-dpdk.c +++ b/src/runmode-dpdk.c @@ -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"); }