From: Sergei Trofimovich <slyich@gmail.com>
To: systemtap@sourceware.org
Cc: Sergei Trofimovich <slyich@gmail.com>
Subject: [PATCH] bpf-translate.cxx: fix build against upcoming `gcc-14` (`-Werror=calloc-transposed-args`)
Date: Fri, 22 Dec 2023 19:42:38 +0000 [thread overview]
Message-ID: <20231222194238.2461516-1-slyich@gmail.com> (raw)
`gcc-14` added a new `-Wcalloc-transposed-args` warning recently. It
detected minor infelicity in `calloc()` API usage in `systemtap`:
bpf-translate.cxx: In function 'bpf::BPF_Section* bpf::output_probe(BPF_Output&, program&, const std::string&, unsigned int)':
bpf-translate.cxx:5044:39: error: 'void* calloc(size_t, size_t)' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
5044 | bpf_insn *buf = (bpf_insn*) calloc (sizeof(bpf_insn), ninsns);
| ^~~~~~~~~~~~~~~~
bpf-translate.cxx:5044:39: note: earlier argument should specify number of elements, later size of each element
---
bpf-translate.cxx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/bpf-translate.cxx b/bpf-translate.cxx
index 1a9302463..aa8ef65ce 100644
--- a/bpf-translate.cxx
+++ b/bpf-translate.cxx
@@ -5041,9 +5041,9 @@ output_probe(BPF_Output &eo, program &prog,
}
}
- bpf_insn *buf = (bpf_insn*) calloc (sizeof(bpf_insn), ninsns);
+ bpf_insn *buf = (bpf_insn*) calloc (ninsns, sizeof(bpf_insn));
assert (buf);
- Elf64_Rel *rel = (Elf64_Rel*) calloc (sizeof(Elf64_Rel), nreloc);
+ Elf64_Rel *rel = (Elf64_Rel*) calloc (nreloc, sizeof(Elf64_Rel));
assert (rel);
unsigned i = 0, r = 0;
--
2.42.0
reply other threads:[~2023-12-22 19:42 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20231222194238.2461516-1-slyich@gmail.com \
--to=slyich@gmail.com \
--cc=systemtap@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).