summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatteo Croce <teknoraver@meta.com>2025-07-17 22:03:37 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-08-20 18:41:07 +0200
commit68c4dd208875aeea90f48b40f2cf841de6f94c2b (patch)
tree679d4b95e08c8b5531472224796807a68990e6ad
parentba11b0f3e9a97661f6caeee3dfc633af8ecee5a5 (diff)
libbpf: Fix warning in calloc() usage
[ Upstream commit 0ee30d937c147fc14c4b49535181d437cd2fde7a ] When compiling libbpf with some compilers, this warning is triggered: libbpf.c: In function ‘bpf_object__gen_loader’: libbpf.c:9209:28: error: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Werror=calloc-transposed-args] 9209 | gen = calloc(sizeof(*gen), 1); | ^ libbpf.c:9209:28: note: earlier argument should specify number of elements, later size of each element Fix this by inverting the calloc() arguments. Signed-off-by: Matteo Croce <teknoraver@meta.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: Yonghong Song <yonghong.song@linux.dev> Link: https://lore.kernel.org/bpf/20250717200337.49168-1-technoboy85@gmail.com Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--tools/lib/bpf/libbpf.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 6401dd3bd35f..8fe427960eee 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -9221,7 +9221,7 @@ int bpf_object__gen_loader(struct bpf_object *obj, struct gen_loader_opts *opts)
return libbpf_err(-EFAULT);
if (!OPTS_VALID(opts, gen_loader_opts))
return libbpf_err(-EINVAL);
- gen = calloc(sizeof(*gen), 1);
+ gen = calloc(1, sizeof(*gen));
if (!gen)
return libbpf_err(-ENOMEM);
gen->opts = opts;