[PATCH] selftests/bpf: Fix redefinition of 'off' as different kind of symbol

Brahmajit Das posted 1 patch 3 months, 3 weeks ago
There is a newer version of this series
.../selftests/bpf/progs/verifier_global_ptr_args.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
[PATCH] selftests/bpf: Fix redefinition of 'off' as different kind of symbol
Posted by Brahmajit Das 3 months, 3 weeks ago
This fixes the following build error

   CLNG-BPF [test_progs] verifier_global_ptr_args.bpf.o
progs/verifier_global_ptr_args.c:228:5: error: redefinition of 'off' as
different kind of symbol
   228 | u32 off;
       |     ^

Suggested-by: Yonghong Song <yonghong.song@linux.dev>
Signed-off-by: Brahmajit Das <listout@listout.xyz>
---
Please refer: https://lore.kernel.org/bpf/5ca1d6a6-5e5a-3485-d3cd-f9439612d1f3@loongson.cn/
---
 .../selftests/bpf/progs/verifier_global_ptr_args.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/tools/testing/selftests/bpf/progs/verifier_global_ptr_args.c b/tools/testing/selftests/bpf/progs/verifier_global_ptr_args.c
index 6630a92b1b47..1204fbc58178 100644
--- a/tools/testing/selftests/bpf/progs/verifier_global_ptr_args.c
+++ b/tools/testing/selftests/bpf/progs/verifier_global_ptr_args.c
@@ -225,7 +225,7 @@ int trusted_to_untrusted(void *ctx)
 }
 
 char mem[16];
-u32 off;
+u32 offset;
 
 SEC("tp_btf/sys_enter")
 __success
@@ -240,9 +240,9 @@ int anything_to_untrusted(void *ctx)
 	/* scalar to untrusted */
 	subprog_untrusted(0);
 	/* variable offset to untrusted (map) */
-	subprog_untrusted((void *)mem + off);
+	subprog_untrusted((void *)mem + offset);
 	/* variable offset to untrusted (trusted) */
-	subprog_untrusted((void *)bpf_get_current_task_btf() + off);
+	subprog_untrusted((void *)bpf_get_current_task_btf() + offset);
 	return 0;
 }
 
@@ -298,12 +298,12 @@ int anything_to_untrusted_mem(void *ctx)
 	/* scalar to untrusted mem */
 	subprog_void_untrusted(0);
 	/* variable offset to untrusted mem (map) */
-	subprog_void_untrusted((void *)mem + off);
+	subprog_void_untrusted((void *)mem + offset);
 	/* variable offset to untrusted mem (trusted) */
-	subprog_void_untrusted(bpf_get_current_task_btf() + off);
+	subprog_void_untrusted(bpf_get_current_task_btf() + offset);
 	/* variable offset to untrusted char/enum (map) */
-	subprog_char_untrusted(mem + off);
-	subprog_enum_untrusted((void *)mem + off);
+	subprog_char_untrusted(mem + offset);
+	subprog_enum_untrusted((void *)mem + offset);
 	return 0;
 }
 
-- 
2.51.0
Re: [PATCH] selftests/bpf: Fix redefinition of 'off' as different kind of symbol
Posted by Yonghong Song 3 months, 3 weeks ago

On 10/17/25 8:54 AM, Brahmajit Das wrote:
> This fixes the following build error
>
>     CLNG-BPF [test_progs] verifier_global_ptr_args.bpf.o
> progs/verifier_global_ptr_args.c:228:5: error: redefinition of 'off' as
> different kind of symbol
>     228 | u32 off;
>         |     ^
>
> Suggested-by: Yonghong Song <yonghong.song@linux.dev>
> Signed-off-by: Brahmajit Das <listout@listout.xyz>

Please add more context in the commit message about where the
redefinition of 'off' comes from.

Also, please replace [PATCH] to [PATCH bpf] so CI can do proper testing.
So in the next revision you can have [PATCH bpf v2].

With the changes in the above, you can carry my ack.

Acked-by: Yonghong Song <yonghong.song@linux.dev>

> ---
> Please refer: https://lore.kernel.org/bpf/5ca1d6a6-5e5a-3485-d3cd-f9439612d1f3@loongson.cn/
> ---
>   .../selftests/bpf/progs/verifier_global_ptr_args.c | 14 +++++++-------
>   1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/progs/verifier_global_ptr_args.c b/tools/testing/selftests/bpf/progs/verifier_global_ptr_args.c
> index 6630a92b1b47..1204fbc58178 100644
> --- a/tools/testing/selftests/bpf/progs/verifier_global_ptr_args.c
> +++ b/tools/testing/selftests/bpf/progs/verifier_global_ptr_args.c
> @@ -225,7 +225,7 @@ int trusted_to_untrusted(void *ctx)
>   }
>   
>   char mem[16];
> -u32 off;
> +u32 offset;

[...]