CLEANUP: Do not use a fixed type for 'sizeof' in 'calloc'

Changes performed using the following coccinelle patch:

    @@
    type T;
    expression E;
    expression t;
    @@

    (
      t = calloc(E, sizeof(*t))
    |
    - t = calloc(E, sizeof(T))
    + t = calloc(E, sizeof(*t))
    )

Looking through the commit history, grepping for coccinelle shows that the same
replacement with a different patch was already performed in the past in commit
02779b6263.
This commit is contained in:
Tim Duesterhus
2020-09-12 20:26:43 +02:00
committed by Willy Tarreau
parent b53dd03dc0
commit e52b6e5456
13 changed files with 20 additions and 17 deletions

View File

@@ -799,7 +799,8 @@ void mworker_reload()
old_argc++;
/* 1 for haproxy -sf, 2 for -x /socket */
next_argv = calloc(old_argc + 1 + 2 + mworker_child_nb() + nb_oldpids + 1, sizeof(char *));
next_argv = calloc(old_argc + 1 + 2 + mworker_child_nb() + nb_oldpids + 1,
sizeof(*next_argv));
if (next_argv == NULL)
goto alloc_error;
@@ -1133,7 +1134,7 @@ static char **copy_argv(int argc, char **argv)
{
char **newargv, **retargv;
newargv = calloc(argc + 2, sizeof(char *));
newargv = calloc(argc + 2, sizeof(*newargv));
if (newargv == NULL) {
ha_warning("Cannot allocate memory\n");
return NULL;