nucleo | ca75cd8 | 2024-01-18 16:48:35 +0200 | [diff] [blame] | 1 | From b184d103bd767e2286cdb2b0639a2470dce205d5 Mon Sep 17 00:00:00 2001 |
| 2 | From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= <toke@redhat.com> |
| 3 | Date: Thu, 18 Jan 2024 13:22:47 +0100 |
| 4 | Subject: [PATCH] Fix transposed calloc() arguments |
| 5 | MIME-Version: 1.0 |
| 6 | Content-Type: text/plain; charset=UTF-8 |
| 7 | Content-Transfer-Encoding: 8bit |
| 8 | |
| 9 | Calls to calloc() are supposed to have the number of elements as the first |
| 10 | argument, but we erroneously transposed the arguments in a couple of places. It |
| 11 | seems GCC 14 has started to warn about this, which exposed this as build |
| 12 | breakage. |
| 13 | |
| 14 | Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com> |
| 15 | --- |
| 16 | lib/util/params.c | 2 +- |
| 17 | lib/util/xpcapng.c | 6 +++--- |
| 18 | xdp-trafficgen/xdp-trafficgen.c | 4 ++-- |
| 19 | 3 files changed, 6 insertions(+), 6 deletions(-) |
| 20 | |
| 21 | diff --git a/lib/util/xpcapng.c b/lib/util/xpcapng.c |
| 22 | index e453b88..8cfc947 100644 |
| 23 | --- a/lib/util/xpcapng.c |
| 24 | +++ b/lib/util/xpcapng.c |
| 25 | @@ -226,7 +226,7 @@ static bool pcapng_write_shb(struct xpcapng_dumper *pd, const char *comment, |
| 26 | shb_length += sizeof(uint32_t); |
| 27 | |
| 28 | /* Allocate the SHB and fill it. */ |
| 29 | - shb = calloc(shb_length, 1); |
| 30 | + shb = calloc(1, shb_length); |
| 31 | if (shb == NULL) { |
| 32 | errno = ENOMEM; |
| 33 | return false; |
| 34 | @@ -318,7 +318,7 @@ static bool pcapng_write_idb(struct xpcapng_dumper *pd, const char *name, |
| 35 | idb_length += sizeof(uint32_t); |
| 36 | |
| 37 | /* Allocate the IDB and fill it. */ |
| 38 | - idb = calloc(idb_length, 1); |
| 39 | + idb = calloc(1, idb_length); |
| 40 | if (idb == NULL) { |
| 41 | errno = ENOMEM; |
| 42 | return false; |
| 43 | @@ -549,7 +549,7 @@ struct xpcapng_dumper *xpcapng_dump_open(const char *file, |
| 44 | goto error_exit; |
| 45 | } |
| 46 | |
| 47 | - pd = calloc(sizeof(*pd), 1); |
| 48 | + pd = calloc(1, sizeof(*pd)); |
| 49 | if (pd == NULL) { |
| 50 | errno = ENOMEM; |
| 51 | goto error_exit; |
| 52 | -- |
| 53 | 2.43.0 |
| 54 | |