From: Sergei Trofimovich <slyich@gmail.com>
To: elfutils-devel@sourceware.org
Cc: Sergei Trofimovich <slyich@gmail.com>
Subject: [PATCH] tests: fix build against upcoming `gcc-14` (`-Werror=calloc-transposed-args`)
Date: Thu, 21 Dec 2023 09:23:30 +0000 [thread overview]
Message-ID: <20231221092330.1419516-1-slyich@gmail.com> (raw)
`gcc-14` added a new `-Wcalloc-transposed-args` warning recently. It
detected minor infelicity in `calloc()` API usage in `elfutils`:
elfstrmerge.c: In function 'main':
elfstrmerge.c:450:32: error:
'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
450 | newscnbufs = calloc (sizeof (void *), newshnums);
| ^~~~
elfstrmerge.c:450:32: note: earlier argument should specify number of elements, later size of each element
Signed-off-by: Sergei Trofimovich <slyich@gmail.com>
---
tests/elfstrmerge.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tests/elfstrmerge.c b/tests/elfstrmerge.c
index 56350bb9..4eb58bbb 100644
--- a/tests/elfstrmerge.c
+++ b/tests/elfstrmerge.c
@@ -447,7 +447,7 @@ main (int argc, char **argv)
}
newshnums = shdrnum - 1;
- newscnbufs = calloc (sizeof (void *), newshnums);
+ newscnbufs = calloc (newshnums, sizeof (void *));
if (newscnbufs == NULL)
fail_errno ("Couldn't allocate memory for new section buffers", NULL);
--
2.42.0
next reply other threads:[~2023-12-21 9:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-21 9:23 Sergei Trofimovich [this message]
2023-12-21 21:23 ` Mark Wielaard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231221092330.1419516-1-slyich@gmail.com \
--to=slyich@gmail.com \
--cc=elfutils-devel@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).