CLEANUP: Re-apply xalloc_size.cocci (2)
authorTim Duesterhus <tim@bastelstu.be>
Wed, 1 Jun 2022 19:58:37 +0000 (21:58 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 2 Jun 2022 12:12:18 +0000 (14:12 +0200)
This reapplies the xalloc_size.cocci patch across the whole `src/` tree.

see 16cc16dd8235e7eb6c38b7abd210bd1e1d96b1d9
see 63ee0e4c01b94aee5fc6c6dd98cfc4480ae5ea46

src/ncbuf.c
src/proto_quic.c
src/quic_sock.c

index 1944cfe..adb32b5 100644 (file)
@@ -726,7 +726,7 @@ struct rand_off {
 static struct rand_off *ncb_generate_rand_off(const struct ncbuf *buf)
 {
        struct rand_off *roff;
-       roff = calloc(1, sizeof(struct rand_off));
+       roff = calloc(1, sizeof(*roff));
        BUG_ON(!roff);
 
        roff->off = rand() % (ncb_size(buf));
index 55aa4b5..ab1bef1 100644 (file)
@@ -703,7 +703,7 @@ static int quic_alloc_dghdlrs(void)
 {
        int i;
 
-       quic_dghdlrs = calloc(global.nbthread, sizeof(struct quic_dghdlr));
+       quic_dghdlrs = calloc(global.nbthread, sizeof(*quic_dghdlrs));
        if (!quic_dghdlrs) {
                ha_alert("Failed to allocate the quic datagram handlers.\n");
                return 0;
index 6207af7..a391006 100644 (file)
@@ -466,7 +466,8 @@ static int quic_alloc_accept_queues(void)
 {
        int i;
 
-       quic_accept_queues = calloc(global.nbthread, sizeof(struct quic_accept_queue));
+       quic_accept_queues = calloc(global.nbthread,
+                                   sizeof(*quic_accept_queues));
        if (!quic_accept_queues) {
                ha_alert("Failed to allocate the quic accept queues.\n");
                return 0;