* [PATCH v2] libbpf: Fix build warning on ref_ctr_off
@ 2022-12-19 19:15 Khem Raj
2022-12-21 0:00 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Khem Raj @ 2022-12-19 19:15 UTC (permalink / raw)
To: bpf
Cc: Khem Raj, Alexei Starovoitov, Daniel Borkmann, Song Liu,
Yonghong Song, Jiri Olsa, Paul Walmsley, Palmer Dabbelt,
Nathan Chancellor, Nick Desaulniers, Andrii Nakryiko
Clang warns on 32-bit ARM on this comparision
libbpf.c:10497:18: error: result of comparison of constant 4294967296 with expression of type 'size_t' (aka 'unsigned int') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
if (ref_ctr_off >= (1ULL << PERF_UPROBE_REF_CTR_OFFSET_BITS))
~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
typecast ref_ctr_off to __u64 in the check conditional, it is false on 32bit anyways.
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Song Liu <song@kernel.org>
Cc: Yonghong Song <yhs@fb.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
v2: Typecast ref_ctr_off to __u64 instead of checking platform word size
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 2a82f49ce16f..a5c67a3c93c5 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -9903,7 +9903,7 @@ static int perf_event_open_probe(bool uprobe, bool retprobe, const char *name,
char errmsg[STRERR_BUFSIZE];
int type, pfd;
- if (ref_ctr_off >= (1ULL << PERF_UPROBE_REF_CTR_OFFSET_BITS))
+ if ((__u64)ref_ctr_off >= (1ULL << PERF_UPROBE_REF_CTR_OFFSET_BITS))
return -EINVAL;
memset(&attr, 0, attr_sz);
--
2.39.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v2] libbpf: Fix build warning on ref_ctr_off
2022-12-19 19:15 [PATCH v2] libbpf: Fix build warning on ref_ctr_off Khem Raj
@ 2022-12-21 0:00 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-12-21 0:00 UTC (permalink / raw)
To: Khem Raj
Cc: bpf, ast, daniel, song, yhs, jolsa, paul.walmsley, palmer, nathan,
ndesaulniers, andrii.nakryiko
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:
On Mon, 19 Dec 2022 11:15:26 -0800 you wrote:
> Clang warns on 32-bit ARM on this comparision
>
> libbpf.c:10497:18: error: result of comparison of constant 4294967296 with expression of type 'size_t' (aka 'unsigned int') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
> if (ref_ctr_off >= (1ULL << PERF_UPROBE_REF_CTR_OFFSET_BITS))
> ~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> typecast ref_ctr_off to __u64 in the check conditional, it is false on 32bit anyways.
>
> [...]
Here is the summary with links:
- [v2] libbpf: Fix build warning on ref_ctr_off
https://git.kernel.org/bpf/bpf-next/c/1520e8466d68
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] 2+ messages in thread
end of thread, other threads:[~2022-12-21 0:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-19 19:15 [PATCH v2] libbpf: Fix build warning on ref_ctr_off Khem Raj
2022-12-21 0:00 ` 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