BUILD: address a few remaining calloc(size, n) cases
In issue #2427 Ilya reports that gcc-14 rightfully complains about
sizeof() being placed in the left term of calloc(). There's no impact
but it's a bad pattern that gets copy-pasted over time. Let's fix the
few remaining occurrences (debug.c, halog, udp-perturb).
This can be backported to all branches, and the irrelevant parts dropped.
(cherry picked from commit ab8928b9dbbae77602b1cd50b0f7189835df9164)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit e0267158f01a593bf9b35ceef2adf1929f46938b)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit 8330d9f720f4d8c993749b83e5554598b84195ba)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 3b1094a85555bf14980fa492c40327955ed519ea)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 97516d4d5d804e1e8150f67dcf76a0dc89bcaa8b)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
diff --git a/admin/halog/halog.c b/admin/halog/halog.c
index 900cf5d..3fd5231 100644
--- a/admin/halog/halog.c
+++ b/admin/halog/halog.c
@@ -376,7 +376,7 @@
struct eb32_node *n;
if (!t) {
- t = calloc(sizeof(*t), 1);
+ t = calloc(1, sizeof(*t));
if (unlikely(!t)) {
fprintf(stderr, "%s: not enough memory\n", __FUNCTION__);
exit(1);
@@ -404,7 +404,7 @@
struct eb32_node *n;
if (!t) {
- t = calloc(sizeof(*t), 1);
+ t = calloc(1, sizeof(*t));
if (unlikely(!t)) {
fprintf(stderr, "%s: not enough memory\n", __FUNCTION__);
exit(1);
diff --git a/src/debug.c b/src/debug.c
index c2b43cc..eb8d05d 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -900,7 +900,7 @@
*(uint8_t *)ptr = new;
}
- tctx = calloc(sizeof(*tctx), count + 2);
+ tctx = calloc(count + 2, sizeof(*tctx));
if (!tctx)
goto fail;