Skip to contentSkip to conversation

libbpf: Make btf_name_info.needs_size unsigned

PATCH In review Ilya Leoshkevich 2 participants 2 messages Jun 27, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libbpf: Make btf_name_info.needs_size unsigned

Clang build of libbpf fails with:

tools/lib/bpf/btf_relocate.c:206:23: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
206 | info[id].needs_size = true;
| ^ ~~~~

Resolve the issue by making needs_size unsigned.

Fixes 19e00c897d50 ("libbpf: Split BTF relocation")
---
 tools/lib/bpf/btf_relocate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/bpf/btf_relocate.c +1 -1
index 2281dbbafa11..d2551d7f33c8 100644
@@ -58,7 +58,7 @@ struct btf_relocate {
 struct btf_name_info {
 	const char *name;
 	/* set when search requires a size match */
-	int needs_size:1,
+	unsigned needs_size:1,
 	    size:31;
 	__u32 id;
 };
Signature · 1 line
2.45.2
#1 lore raw
Quoted 10 lines · Ilya Leoshkevich

Clang build of libbpf fails with:

tools/lib/bpf/btf_relocate.c:206:23: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
206 | info[id].needs_size = true;
| ^ ~~~~

Resolve the issue by making needs_size unsigned.

Fixes 19e00c897d50 ("libbpf: Split BTF relocation")

Thanks for the fix! This one should already be resolved in bpf-next via

0f31c2c61f69 ("libbpf: Fix clang compilation error in btf_relocate.c")

Quoted 17 lines
---
 tools/lib/bpf/btf_relocate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/bpf/btf_relocate.c +1 -1
index 2281dbbafa11..d2551d7f33c8 100644
@@ -58,7 +58,7 @@ struct btf_relocate {
 struct btf_name_info {
 	const char *name;
 	/* set when search requires a size match */
-	int needs_size:1,
+	unsigned needs_size:1,
 	    size:31;
 	__u32 id;
 };