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.
This commit is contained in:
parent
4559470728
commit
ab8928b9db
|
@ -410,7 +410,7 @@ struct timer *insert_timer(struct eb_root *r, struct timer **alloc, int v)
|
||||||
struct eb32_node *n;
|
struct eb32_node *n;
|
||||||
|
|
||||||
if (!t) {
|
if (!t) {
|
||||||
t = calloc(sizeof(*t), 1);
|
t = calloc(1, sizeof(*t));
|
||||||
if (unlikely(!t)) {
|
if (unlikely(!t)) {
|
||||||
fprintf(stderr, "%s: not enough memory\n", __FUNCTION__);
|
fprintf(stderr, "%s: not enough memory\n", __FUNCTION__);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -438,7 +438,7 @@ struct timer *insert_value(struct eb_root *r, struct timer **alloc, int v)
|
||||||
struct eb32_node *n;
|
struct eb32_node *n;
|
||||||
|
|
||||||
if (!t) {
|
if (!t) {
|
||||||
t = calloc(sizeof(*t), 1);
|
t = calloc(1, sizeof(*t));
|
||||||
if (unlikely(!t)) {
|
if (unlikely(!t)) {
|
||||||
fprintf(stderr, "%s: not enough memory\n", __FUNCTION__);
|
fprintf(stderr, "%s: not enough memory\n", __FUNCTION__);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
|
@ -489,7 +489,7 @@ int main(int argc, char **argv)
|
||||||
if (addr_to_ss(argv[optind+1], &srv_addr, &err) < 0)
|
if (addr_to_ss(argv[optind+1], &srv_addr, &err) < 0)
|
||||||
die(1, "parsing server address: %s\n", err.msg);
|
die(1, "parsing server address: %s\n", err.msg);
|
||||||
|
|
||||||
pfd = calloc(sizeof(struct pollfd), MAXCONN + 1);
|
pfd = calloc(MAXCONN + 1, sizeof(struct pollfd));
|
||||||
if (!pfd)
|
if (!pfd)
|
||||||
die(1, "out of memory\n");
|
die(1, "out of memory\n");
|
||||||
|
|
||||||
|
|
|
@ -1293,7 +1293,7 @@ static int debug_parse_delay_inj(char **args, char *payload, struct appctx *appc
|
||||||
|
|
||||||
_HA_ATOMIC_INC(&debug_commands_issued);
|
_HA_ATOMIC_INC(&debug_commands_issued);
|
||||||
|
|
||||||
tctx = calloc(sizeof(*tctx), 2);
|
tctx = calloc(2, sizeof(*tctx));
|
||||||
if (!tctx)
|
if (!tctx)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
@ -1427,7 +1427,7 @@ static int debug_parse_cli_sched(char **args, char *payload, struct appctx *appc
|
||||||
*(uint8_t *)ptr = new;
|
*(uint8_t *)ptr = new;
|
||||||
}
|
}
|
||||||
|
|
||||||
tctx = calloc(sizeof(*tctx), count + 2);
|
tctx = calloc(count + 2, sizeof(*tctx));
|
||||||
if (!tctx)
|
if (!tctx)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue