summaryrefslogtreecommitdiff
path: root/tools/bpf
diff options
context:
space:
mode:
authorTiezhu Yang <yangtiezhu@loongson.cn>2024-01-16 14:19:20 +0800
committerSasha Levin <sashal@kernel.org>2024-03-26 18:21:17 -0400
commite0d29c4def1591ba5a8ffcb4028e7f86e959c50c (patch)
treeac881ae3c8d5e1c8e64b85516be7cfc8d3485d75 /tools/bpf
parent3b71a6981ef8c0f6f52ed0ac94536c1b960724a1 (diff)
downloadlinux-e0d29c4def1591ba5a8ffcb4028e7f86e959c50c.tar.gz
linux-e0d29c4def1591ba5a8ffcb4028e7f86e959c50c.tar.bz2
linux-e0d29c4def1591ba5a8ffcb4028e7f86e959c50c.zip
bpftool: Silence build warning about calloc()
[ Upstream commit f5f30386c78105cba520e443a6a9ee945ec1d066 ] There exists the following warning when building bpftool: CC prog.o prog.c: In function ‘profile_open_perf_events’: prog.c:2301:24: warning: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Wcalloc-transposed-args] 2301 | sizeof(int), obj->rodata->num_cpu * obj->rodata->num_metric); | ^~~ prog.c:2301:24: note: earlier argument should specify number of elements, later size of each element Tested with the latest upstream GCC which contains a new warning option -Wcalloc-transposed-args. The first argument to calloc is documented to be number of elements in array, while the second argument is size of each element, just switch the first and second arguments of calloc() to silence the build warning, compile tested only. Fixes: 47c09d6a9f67 ("bpftool: Introduce "prog profile" command") Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Reviewed-by: Quentin Monnet <quentin@isovalent.com> Link: https://lore.kernel.org/bpf/20240116061920.31172-1-yangtiezhu@loongson.cn Signed-off-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'tools/bpf')
-rw-r--r--tools/bpf/bpftool/prog.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
index bdd4d3b12f6c..afb28fcc6678 100644
--- a/tools/bpf/bpftool/prog.c
+++ b/tools/bpf/bpftool/prog.c
@@ -2098,7 +2098,7 @@ static int profile_open_perf_events(struct profiler_bpf *obj)
int map_fd;
profile_perf_events = calloc(
- sizeof(int), obj->rodata->num_cpu * obj->rodata->num_metric);
+ obj->rodata->num_cpu * obj->rodata->num_metric, sizeof(int));
if (!profile_perf_events) {
p_err("failed to allocate memory for perf_event array: %s",
strerror(errno));