diff mbox series

[net-next] net: filter: Avoid shadowing variable in bpf_convert_ctx_access()

Message ID 20250228-fix_filter-v1-1-ce13eae66fe9@debian.org (mailing list archive)
State Accepted
Commit 122f1fd14f44d8d6f0113b9db8acbdd9636d45b4
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: filter: Avoid shadowing variable in bpf_convert_ctx_access() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 18 of 18 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 26 this patch: 26
netdev/checkpatch warning WARNING: line length of 99 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 6 this patch: 6
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2025-03-01--03-00 (tests: 893)

Commit Message

Breno Leitao Feb. 28, 2025, 6:43 p.m. UTC
Rename the local variable 'off' to 'offset' to avoid shadowing the existing
'off' variable that is declared as an `int` in the outer scope of
bpf_convert_ctx_access().

This fixes a compiler warning:

 net/core/filter.c:9679:8: warning: declaration shadows a local variable [-Wshadow]

Signed-off-by: Breno Leitao <leitao@debian.org>
---
 net/core/filter.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)


---
base-commit: 76544811c850a1f4c055aa182b513b7a843868ea
change-id: 20250228-fix_filter-5385ff6e154b

Best regards,

Comments

Yonghong Song Feb. 28, 2025, 6:55 p.m. UTC | #1
On 2/28/25 10:43 AM, Breno Leitao wrote:
> Rename the local variable 'off' to 'offset' to avoid shadowing the existing
> 'off' variable that is declared as an `int` in the outer scope of
> bpf_convert_ctx_access().
>
> This fixes a compiler warning:
>
>   net/core/filter.c:9679:8: warning: declaration shadows a local variable [-Wshadow]
>
> Signed-off-by: Breno Leitao <leitao@debian.org>

Make sense to me.

Acked-by: Yonghong Song <yonghong.song@linux.dev>
patchwork-bot+netdevbpf@kernel.org March 3, 2025, 11:36 p.m. UTC | #2
Hello:

This patch was applied to bpf/bpf-next.git (master)
by Martin KaFai Lau <martin.lau@kernel.org>:

On Fri, 28 Feb 2025 10:43:34 -0800 you wrote:
> Rename the local variable 'off' to 'offset' to avoid shadowing the existing
> 'off' variable that is declared as an `int` in the outer scope of
> bpf_convert_ctx_access().
> 
> This fixes a compiler warning:
> 
>  net/core/filter.c:9679:8: warning: declaration shadows a local variable [-Wshadow]
> 
> [...]

Here is the summary with links:
  - [net-next] net: filter: Avoid shadowing variable in bpf_convert_ctx_access()
    https://git.kernel.org/bpf/bpf-next/c/122f1fd14f44

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/core/filter.c b/net/core/filter.c
index 2ec162dd83c46..c23c969cf7d83 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -9635,7 +9635,7 @@  static u32 bpf_convert_ctx_access(enum bpf_access_type type,
 
 	case offsetof(struct __sk_buff, queue_mapping):
 		if (type == BPF_WRITE) {
-			u32 off = bpf_target_off(struct sk_buff, queue_mapping, 2, target_size);
+			u32 offset = bpf_target_off(struct sk_buff, queue_mapping, 2, target_size);
 
 			if (BPF_CLASS(si->code) == BPF_ST && si->imm >= NO_QUEUE_MAPPING) {
 				*insn++ = BPF_JMP_A(0); /* noop */
@@ -9644,7 +9644,7 @@  static u32 bpf_convert_ctx_access(enum bpf_access_type type,
 
 			if (BPF_CLASS(si->code) == BPF_STX)
 				*insn++ = BPF_JMP_IMM(BPF_JGE, si->src_reg, NO_QUEUE_MAPPING, 1);
-			*insn++ = BPF_EMIT_STORE(BPF_H, si, off);
+			*insn++ = BPF_EMIT_STORE(BPF_H, si, offset);
 		} else {
 			*insn++ = BPF_LDX_MEM(BPF_H, si->dst_reg, si->src_reg,
 					      bpf_target_off(struct sk_buff,