* [PATCH bpf-next] libbpf: fix warning
@ 2025-07-17 20:03 Matteo Croce
2025-07-18 4:06 ` Yonghong Song
2025-07-18 15:40 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Matteo Croce @ 2025-07-17 20:03 UTC (permalink / raw)
To: bpf; +Cc: linux-kernel, Matteo Croce
From: Matteo Croce <teknoraver@meta.com>
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>
---
tools/lib/bpf/libbpf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index aee36402f0a3..af85989ae2c9 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -9210,7 +9210,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;
--
2.39.5 (Apple Git-154)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next] libbpf: fix warning
2025-07-17 20:03 [PATCH bpf-next] libbpf: fix warning Matteo Croce
@ 2025-07-18 4:06 ` Yonghong Song
2025-07-18 15:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Yonghong Song @ 2025-07-18 4:06 UTC (permalink / raw)
To: Matteo Croce, bpf; +Cc: linux-kernel, Matteo Croce
On 7/17/25 1:03 PM, Matteo Croce wrote:
> From: Matteo Croce <teknoraver@meta.com>
>
> 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>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next] libbpf: fix warning
2025-07-17 20:03 [PATCH bpf-next] libbpf: fix warning Matteo Croce
2025-07-18 4:06 ` Yonghong Song
@ 2025-07-18 15:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-07-18 15:40 UTC (permalink / raw)
To: Matteo Croce; +Cc: bpf, linux-kernel, teknoraver
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:
On Thu, 17 Jul 2025 22:03:37 +0200 you wrote:
> From: Matteo Croce <teknoraver@meta.com>
>
> 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
>
> [...]
Here is the summary with links:
- [bpf-next] libbpf: fix warning
https://git.kernel.org/bpf/bpf-next/c/0ee30d937c14
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-07-18 15:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-17 20:03 [PATCH bpf-next] libbpf: fix warning Matteo Croce
2025-07-18 4:06 ` Yonghong Song
2025-07-18 15:40 ` patchwork-bot+netdevbpf
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 NNTP newsgroup(s).