Skip to contentSkip to conversation

tools/resolve_btfids: fix comparison of distinct pointer types warning in resolve_btfids

PATCH Applied Liwei Song 4 participants 4 messages Jul 22, 2024 BPF

lore
Share & tools
lore

Liwei Song

author
#0 lore raw

PATCH 1/1 tools/resolve_btfids: fix comparison of distinct pointer types warning in resolve_btfids

Add a type cast for set8->pairs to fix below compile warning:

main.c: In function 'sets_patch':
main.c:699:50: warning: comparison of distinct pointer types lacks a cast
699 | BUILD_BUG_ON(set8->pairs != &set8->pairs[0].id);
| ^~

Fixes 9707ac4fe2f5 ("tools/resolve_btfids: Refactor set sorting with types from btf_ids.h")
---
 tools/bpf/resolve_btfids/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/bpf/resolve_btfids/main.c +1 -1
index af393c7dee1f..b3edc239fe56 100644
@@ -696,7 +696,7 @@ static int sets_patch(struct object *obj)
 			 * Make sure id is at the beginning of the pairs
 			 * struct, otherwise the below qsort would not work.
 			 */
-			BUILD_BUG_ON(set8->pairs != &set8->pairs[0].id);
+			BUILD_BUG_ON((u32 *)set8->pairs != &set8->pairs[0].id);
 			qsort(set8->pairs, set8->cnt, sizeof(set8->pairs[0]), cmp_id);
 
 			/*
Signature · 1 line
1.8.3.1
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Liwei Song

Add a type cast for set8->pairs to fix below compile warning:

main.c: In function 'sets_patch':
main.c:699:50: warning: comparison of distinct pointer types lacks a cast
699 | BUILD_BUG_ON(set8->pairs != &set8->pairs[0].id);
| ^~

Fixes 9707ac4fe2f5 ("tools/resolve_btfids: Refactor set sorting with types from btf_ids.h")

jirka

Quoted 20 lines
---
 tools/bpf/resolve_btfids/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/bpf/resolve_btfids/main.c +1 -1
index af393c7dee1f..b3edc239fe56 100644
@@ -696,7 +696,7 @@ static int sets_patch(struct object *obj)
 			 * Make sure id is at the beginning of the pairs
 			 * struct, otherwise the below qsort would not work.
 			 */
-			BUILD_BUG_ON(set8->pairs != &set8->pairs[0].id);
+			BUILD_BUG_ON((u32 *)set8->pairs != &set8->pairs[0].id);
 			qsort(set8->pairs, set8->cnt, sizeof(set8->pairs[0]), cmp_id);
 
 			/*
Signature · 1 line
1.8.3.1
#2 lore raw
In reply to Liwei Song
CI has tested the following submission:

Dear patch submitter,

CI has tested the following submission:

Status:     FAILURE
Name:       tools/resolve_btfids: fix comparison of distinct pointer types warning in resolve_btfids
Patchwork:  https://patchwork.kernel.org/project/netdevbpf/list/?series=872877&state=*
Matrix:     https://github.com/kernel-patches/bpf/actions/runs/10037557445

Failed jobs:
test_progs_no_alu32-x86_64-llvm-17: https://github.com/kernel-patches/bpf/actions/runs/10037557445/job/27737836978

First test_progs failure (test_progs_no_alu32-x86_64-llvm-17):
#55 cgrp_local_storage
cgrp2_local_storage:PASS:join_cgroup /cgrp_local_storage 0 nsec #55/2 cgrp_local_storage/attach_cgroup test_attach_cgroup:PASS:skel_open 0 nsec test_attach_cgroup:PASS:prog_attach 0 nsec test_attach_cgroup:PASS:prog_attach 0 nsec test_attach_cgroup:PASS:prog_attach 0 nsec test_attach_cgroup:PASS:start_server 0 nsec test_attach_cgroup:PASS:connect_to_fd 0 nsec test_attach_cgroup:FAIL:map_lookup(socket_cookies) unexpected error: -2 (errno 2)

Please note: this email is coming from an unmonitored mailbox. If you have questions or feedback, please reach out to the Meta Kernel CI team at [email protected].

#3 lore raw
In reply to Liwei Song
This patch was applied to bpf/bpf.git (master) by Daniel Borkmann <[email protected]>:

Hello:

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

Quoted 8 lines · On Mon, 22 Jul 2024 16:32:59 +0800 you wrote:

Add a type cast for set8->pairs to fix below compile warning:

main.c: In function 'sets_patch':
main.c:699:50: warning: comparison of distinct pointer types lacks a cast
699 | BUILD_BUG_ON(set8->pairs != &set8->pairs[0].id);
| ^~

[...]

Here is the summary with links:
- tools/resolve_btfids: fix comparison of distinct pointer types warning in resolve_btfids

    https://git.kernel.org/bpf/bpf/c/13c9b702e6cb

You are awesome, thank you!

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