From: Sebastien GODARD Date: Mon, 9 Jul 2018 15:21:21 +0000 (+0200) Subject: Remove int-in-bool-context warnings X-Git-Tag: v12.0.0~22 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9f63e987503a6435c3fffae2be5f6f6b3da76fc3;p=sysstat Remove int-in-bool-context warnings Recent gcc versions think the code used in SREALLOC() macro might be wrong because we use the result of a multiplication as a boolean value: In file included from sa.h:11, from sadc.c:37: sadc.c: In function ‘sa_sys_init’: sadc.c:336:55: warning: ‘*’ in boolean context, suggest ‘&&’ instead [-Wint-in-bool-context] (size_t) act[i]->msize * (size_t) act[i]->nr_ini * (size_t) act[i]->nr2); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ common.h:125:16: note: in definition of macro ‘SREALLOC’ if (SIZE) { \ ^~~~ Add a comparison to zero to make clear to gcc that the code is actually fine. Signed-off-by: Sebastien GODARD --- diff --git a/common.h b/common.h index e9136fa..09b64ab 100644 --- a/common.h +++ b/common.h @@ -122,7 +122,7 @@ /* Allocate and init structure */ #define SREALLOC(S, TYPE, SIZE) do { \ TYPE *_p_ = S; \ - if (SIZE) { \ + if ((SIZE) != 0) { \ if ((S = (TYPE *) realloc(S, (SIZE))) == NULL) { \ perror("realloc"); \ exit(4); \