From ea67a2edd28fa66403101a554d5bb7df9eae712c Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Mon, 24 Apr 2023 21:39:45 +0200 Subject: [PATCH] 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. --- src/runmode-dpdk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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"); } -- 2.47.2