Skip to contentSkip to conversation

libbpf: fix compilation warning due to mismatched printf format

PATCH Applied Andrii Nakryiko 3 participants 3 messages Feb 9, 2022

Subsystems (2)
lore
Share & tools
lore

Andrii Nakryiko

author maintainer
#0 lore raw

PATCH 1/1 libbpf: fix compilation warning due to mismatched printf format

On ppc64le architecture __s64 is long int and requires %ld. Cast to ssize_t and use %zd to avoid architecture-specific specifiers.

Fixes 4172843ed4a3 ("libbpf: Fix signedness bug in btf_dump_array_data()")
---
 tools/lib/bpf/btf_dump.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/lib/bpf/btf_dump.c +2 -1
index 55aed9e398c3..07ebe70d3a30 100644
@@ -1869,7 +1869,8 @@ static int btf_dump_array_data(struct btf_dump *d,
 	elem_type = skip_mods_and_typedefs(d->btf, elem_type_id, NULL);
 	elem_size = btf__resolve_size(d->btf, elem_type_id);
 	if (elem_size <= 0) {
-		pr_warn("unexpected elem size %lld for array type [%u]\n", elem_size, id);
+		pr_warn("unexpected elem size %zd for array type [%u]\n",
+			(ssize_t)elem_size, id);
 		return -EINVAL;
 	}
 
Signature · 1 line
2.30.2
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Andrii Nakryiko

On ppc64le architecture __s64 is long int and requires %ld. Cast to ssize_t and use %zd to avoid architecture-specific specifiers.

Fixes 4172843ed4a3 ("libbpf: Fix signedness bug in btf_dump_array_data()")
Quoted 9 lines
---
  tools/lib/bpf/btf_dump.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
tools/lib/bpf/btf_dump.c +0 -0
index 55aed9e398c3..07ebe70d3a30 100644

tools/lib/bpf/btf_dump.c static int btf_dump_array_data(struct btf_dump *d, · line 1873

Quoted 6 lines
tools/lib/bpf/btf_dump.c +2 -1
@@ -1869,7 +1869,8 @@ static int btf_dump_array_data(struct btf_dump *d,
  	elem_type = skip_mods_and_typedefs(d->btf, elem_type_id, NULL);
  	elem_size = btf__resolve_size(d->btf, elem_type_id);
  	if (elem_size <= 0) {
-		pr_warn("unexpected elem size %lld for array type [%u]\n", elem_size, id);
+		pr_warn("unexpected elem size %zd for array type [%u]\n",
+			(ssize_t)elem_size, id);

Does using "%ld" and "(long)elem_size" work?

Quoted 3 lines
tools/lib/bpf/btf_dump.c +0 -0
  		return -EINVAL;
  	}
 
#2 lore raw
In reply to Andrii Nakryiko
This patch was applied to bpf/bpf-next.git (master) by Daniel Borkmann <[email protected]>:

Hello:

This patch was applied to bpf/bpf-next.git (master) by Daniel Borkmann <[email protected]>:

Quoted 8 lines · On Tue, 8 Feb 2022 22:39:09 -0800 you wrote:

On ppc64le architecture __s64 is long int and requires %ld. Cast to ssize_t and use %zd to avoid architecture-specific specifiers.

Fixes 4172843ed4a3 ("libbpf: Fix signedness bug in btf_dump_array_data()")
---
 tools/lib/bpf/btf_dump.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Here is the summary with links:
- [bpf-next] libbpf: fix compilation warning due to mismatched printf format

    https://git.kernel.org/bpf/bpf-next/c/dc37dc617fab

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html