All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/1] btf_encoder: Print the u32 overflow check offset as a u64
@ 2026-12-01 18:30 Arnaldo Carvalho de Melo
  2026-12-01 19:08 ` Stephen Brennan
  0 siblings, 1 reply; 2+ messages in thread
From: Arnaldo Carvalho de Melo @ 2026-12-01 18:30 UTC (permalink / raw)
  To: Alan Maguire
  Cc: Jiri Olsa, Clark Williams, dwarves, bpf, Arnaldo Carvalho de Melo,
	Stephen Brennan

From: Arnaldo Carvalho de Melo <acme@redhat.com>

The offset ignored in btf_encoder__encode_cu_variables() is a uint64_t,
printed with %zu.  That matches on 64-bit, where size_t is also 64-bit,
but on 32-bit x86 uint64_t is unsigned long long and gcc rejects it:

  btf_encoder.c:2893:88: error: format '%zu' expects argument of type
  'size_t', but argument 4 has type 'uint64_t' [-Werror=format=]

which breaks a Debug (-Werror) build on i386 since that check was added.
Use PRIu64, inttypes.h is already included.

Fixes: 5b5238c0aaff1dfd ("btf_encoder: Explicitly check addr/size for u32 overflow")
Cc: Alan Maguire <alan.maguire@oracle.com>
Cc: Stephen Brennan <stephen.s.brennan@oracle.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 btf_encoder.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/btf_encoder.c b/btf_encoder.c
index 85376281da076cb2..ca102eb194b80f8d 100644
--- a/btf_encoder.c
+++ b/btf_encoder.c
@@ -2890,7 +2890,7 @@ static int btf_encoder__encode_cu_variables(struct btf_encoder *encoder)
 		}
 		if (addr > UINT32_MAX) {
 			if (encoder->verbose)
-				fprintf(stderr, "Ignoring variable '%s' - its offset %zu doesn't fit in a u32\n",
+				fprintf(stderr, "Ignoring variable '%s' - its offset %" PRIu64 " doesn't fit in a u32\n",
 					name, addr);
 			continue;
 		}
-- 
2.56.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v1 1/1] btf_encoder: Print the u32 overflow check offset as a u64
  2026-12-01 18:30 [PATCH v1 1/1] btf_encoder: Print the u32 overflow check offset as a u64 Arnaldo Carvalho de Melo
@ 2026-12-01 19:08 ` Stephen Brennan
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Brennan @ 2026-12-01 19:08 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Alan Maguire
  Cc: Jiri Olsa, Clark Williams, dwarves, bpf, Arnaldo Carvalho de Melo

On 12/1/26 10:30 AM, Arnaldo Carvalho de Melo wrote:
> From: Arnaldo Carvalho de Melo <acme@redhat.com>
> 
> The offset ignored in btf_encoder__encode_cu_variables() is a uint64_t,
> printed with %zu.  That matches on 64-bit, where size_t is also 64-bit,
> but on 32-bit x86 uint64_t is unsigned long long and gcc rejects it:
> 
>   btf_encoder.c:2893:88: error: format '%zu' expects argument of type
>   'size_t', but argument 4 has type 'uint64_t' [-Werror=format=]
> 
> which breaks a Debug (-Werror) build on i386 since that check was added.
> Use PRIu64, inttypes.h is already included.
> 
> Fixes: 5b5238c0aaff1dfd ("btf_encoder: Explicitly check addr/size for u32 overflow")
> Cc: Alan Maguire <alan.maguire@oracle.com>
> Cc: Stephen Brennan <stephen.s.brennan@oracle.com>
> Cc: Jiri Olsa <jolsa@kernel.org>
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

There's some irony that this print happens in the 32-bit overflow case,
so I should have thought about what happens when size_t is 32-bit.
Thanks for fixing this.

Reviewed-by: Stephen Brennan <stephen.s.brennan@oracle.com>

> ---
>  btf_encoder.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/btf_encoder.c b/btf_encoder.c
> index 85376281da076cb2..ca102eb194b80f8d 100644
> --- a/btf_encoder.c
> +++ b/btf_encoder.c
> @@ -2890,7 +2890,7 @@ static int btf_encoder__encode_cu_variables(struct btf_encoder *encoder)
>  		}
>  		if (addr > UINT32_MAX) {
>  			if (encoder->verbose)
> -				fprintf(stderr, "Ignoring variable '%s' - its offset %zu doesn't fit in a u32\n",
> +				fprintf(stderr, "Ignoring variable '%s' - its offset %" PRIu64 " doesn't fit in a u32\n",
>  					name, addr);
>  			continue;
>  		}


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-01 19:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 18:30 [PATCH v1 1/1] btf_encoder: Print the u32 overflow check offset as a u64 Arnaldo Carvalho de Melo
2026-12-01 19:08 ` Stephen Brennan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.