* [PATCH] bpf: fix -Wshadow warnings
@ 2020-10-26 16:20 Arnd Bergmann
2020-10-26 22:21 ` Andrii Nakryiko
2020-10-27 16:10 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2020-10-26 16:20 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann
Cc: Arnd Bergmann, Martin KaFai Lau, Song Liu, netdev, bpf, linux-kernel
From: Arnd Bergmann <arnd@arndb.de>
There are thousands of warnings about one macro in a W=2 build:
include/linux/filter.h:561:6: warning: declaration of 'ret' shadows a previous local [-Wshadow]
Prefix all the locals in that macro with __ to avoid most of
these warnings.
Fixes: 492ecee892c2 ("bpf: enable program stats")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
include/linux/filter.h | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/include/linux/filter.h b/include/linux/filter.h
index 954f279fde01..20ba04583eaa 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -558,21 +558,21 @@ struct sk_filter {
DECLARE_STATIC_KEY_FALSE(bpf_stats_enabled_key);
#define __BPF_PROG_RUN(prog, ctx, dfunc) ({ \
- u32 ret; \
+ u32 __ret; \
cant_migrate(); \
if (static_branch_unlikely(&bpf_stats_enabled_key)) { \
- struct bpf_prog_stats *stats; \
- u64 start = sched_clock(); \
- ret = dfunc(ctx, (prog)->insnsi, (prog)->bpf_func); \
- stats = this_cpu_ptr(prog->aux->stats); \
- u64_stats_update_begin(&stats->syncp); \
- stats->cnt++; \
- stats->nsecs += sched_clock() - start; \
- u64_stats_update_end(&stats->syncp); \
+ struct bpf_prog_stats *__stats; \
+ u64 __start = sched_clock(); \
+ __ret = dfunc(ctx, (prog)->insnsi, (prog)->bpf_func); \
+ __stats = this_cpu_ptr(prog->aux->stats); \
+ u64_stats_update_begin(&__stats->syncp); \
+ __stats->cnt++; \
+ __stats->nsecs += sched_clock() - __start; \
+ u64_stats_update_end(&__stats->syncp); \
} else { \
- ret = dfunc(ctx, (prog)->insnsi, (prog)->bpf_func); \
+ __ret = dfunc(ctx, (prog)->insnsi, (prog)->bpf_func); \
} \
- ret; })
+ __ret; })
#define BPF_PROG_RUN(prog, ctx) \
__BPF_PROG_RUN(prog, ctx, bpf_dispatcher_nop_func)
--
2.27.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] bpf: fix -Wshadow warnings
2020-10-26 16:20 [PATCH] bpf: fix -Wshadow warnings Arnd Bergmann
@ 2020-10-26 22:21 ` Andrii Nakryiko
2020-10-27 16:10 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Andrii Nakryiko @ 2020-10-26 22:21 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Alexei Starovoitov, Daniel Borkmann, Arnd Bergmann,
Martin KaFai Lau, Song Liu, Networking, bpf, open list
On Mon, Oct 26, 2020 at 12:37 PM Arnd Bergmann <arnd@kernel.org> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> There are thousands of warnings about one macro in a W=2 build:
>
> include/linux/filter.h:561:6: warning: declaration of 'ret' shadows a previous local [-Wshadow]
>
> Prefix all the locals in that macro with __ to avoid most of
> these warnings.
>
> Fixes: 492ecee892c2 ("bpf: enable program stats")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
Acked-by: Andrii Nakryiko <andrii@kernel.org>
> include/linux/filter.h | 22 +++++++++++-----------
> 1 file changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/include/linux/filter.h b/include/linux/filter.h
> index 954f279fde01..20ba04583eaa 100644
> --- a/include/linux/filter.h
> +++ b/include/linux/filter.h
> @@ -558,21 +558,21 @@ struct sk_filter {
> DECLARE_STATIC_KEY_FALSE(bpf_stats_enabled_key);
>
> #define __BPF_PROG_RUN(prog, ctx, dfunc) ({ \
> - u32 ret; \
> + u32 __ret; \
> cant_migrate(); \
> if (static_branch_unlikely(&bpf_stats_enabled_key)) { \
> - struct bpf_prog_stats *stats; \
> - u64 start = sched_clock(); \
> - ret = dfunc(ctx, (prog)->insnsi, (prog)->bpf_func); \
> - stats = this_cpu_ptr(prog->aux->stats); \
> - u64_stats_update_begin(&stats->syncp); \
> - stats->cnt++; \
> - stats->nsecs += sched_clock() - start; \
> - u64_stats_update_end(&stats->syncp); \
> + struct bpf_prog_stats *__stats; \
> + u64 __start = sched_clock(); \
> + __ret = dfunc(ctx, (prog)->insnsi, (prog)->bpf_func); \
> + __stats = this_cpu_ptr(prog->aux->stats); \
> + u64_stats_update_begin(&__stats->syncp); \
> + __stats->cnt++; \
> + __stats->nsecs += sched_clock() - __start; \
> + u64_stats_update_end(&__stats->syncp); \
> } else { \
> - ret = dfunc(ctx, (prog)->insnsi, (prog)->bpf_func); \
> + __ret = dfunc(ctx, (prog)->insnsi, (prog)->bpf_func); \
> } \
> - ret; })
> + __ret; })
>
> #define BPF_PROG_RUN(prog, ctx) \
> __BPF_PROG_RUN(prog, ctx, bpf_dispatcher_nop_func)
> --
> 2.27.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] bpf: fix -Wshadow warnings
2020-10-26 16:20 [PATCH] bpf: fix -Wshadow warnings Arnd Bergmann
2020-10-26 22:21 ` Andrii Nakryiko
@ 2020-10-27 16:10 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2020-10-27 16:10 UTC (permalink / raw)
To: Arnd Bergmann
Cc: ast, daniel, arnd, kafai, songliubraving, netdev, bpf, linux-kernel
Hello:
This patch was applied to bpf/bpf.git (refs/heads/master):
On Mon, 26 Oct 2020 17:20:50 +0100 you wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> There are thousands of warnings about one macro in a W=2 build:
>
> include/linux/filter.h:561:6: warning: declaration of 'ret' shadows a previous local [-Wshadow]
>
> Prefix all the locals in that macro with __ to avoid most of
> these warnings.
>
> [...]
Here is the summary with links:
- bpf: fix -Wshadow warnings
https://git.kernel.org/bpf/bpf/c/343a3e8bc635
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] 3+ messages in thread
end of thread, other threads:[~2020-10-27 16:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-26 16:20 [PATCH] bpf: fix -Wshadow warnings Arnd Bergmann
2020-10-26 22:21 ` Andrii Nakryiko
2020-10-27 16:10 ` 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;
as well as URLs for NNTP newsgroup(s).