Skip to content

Commit 0ee30d9

Browse files
teknoraveranakryiko
authored andcommitted
libbpf: Fix warning in calloc() usage
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 <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Acked-by: Yonghong Song <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 0768e98 commit 0ee30d9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/lib/bpf/libbpf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9210,7 +9210,7 @@ int bpf_object__gen_loader(struct bpf_object *obj, struct gen_loader_opts *opts)
92109210
return libbpf_err(-EFAULT);
92119211
if (!OPTS_VALID(opts, gen_loader_opts))
92129212
return libbpf_err(-EINVAL);
9213-
gen = calloc(sizeof(*gen), 1);
9213+
gen = calloc(1, sizeof(*gen));
92149214
if (!gen)
92159215
return libbpf_err(-ENOMEM);
92169216
gen->opts = opts;

0 commit comments

Comments
 (0)