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.
pull/8762/head
Victor Julien 2 years ago
parent e717c2e0ec
commit ea67a2edd2

@ -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");
}

Loading…
Cancel
Save