Messages in this thread Patch in this message | | | From | Alexander Lobakin <> | Subject | [PATCH net-next 1/2] net/tcp: fix -Wshadow / Sparse shadow warnings in tcp_hash_fail() | Date | Fri, 29 Mar 2024 17:59:59 +0100 |
| |
Fix the following spam coming from <net/tcp_ao.h> when building with W=12 and/or C=1:
Clang:
In file included from drivers/net/ethernet/intel/idpf/idpf_txrx.c:4: In file included from drivers/net/ethernet/intel/idpf/idpf.h:24: In file included from drivers/net/ethernet/intel/idpf/idpf_txrx.h:8: /include/net/tcp.h:2812:3: warning: declaration shadows a local variable [-Wshadow] 2812 | tcp_hash_fail("TCP segment has incorrect auth options set", | ^ /include/net/tcp_ao.h:153:23: note: expanded from macro 'tcp_hash_fail' 153 | const struct tcphdr *th = tcp_hdr(skb); \ | ^ /include/net/tcp.h:2805:23: note: previous declaration is here 2805 | const struct tcphdr *th = tcp_hdr(skb); | ^ /include/net/tcp.h:2820:4: warning: declaration shadows a local variable [-Wshadow] 2820 | tcp_hash_fail("TCP connection can't start/end using TCP-AO", | ^ /include/net/tcp_ao.h:153:23: note: expanded from macro 'tcp_hash_fail' 153 | const struct tcphdr *th = tcp_hdr(skb); \ | ^ /include/net/tcp.h:2805:23: note: previous declaration is here 2805 | const struct tcphdr *th = tcp_hdr(skb); | ^ /include/net/tcp.h:2840:4: warning: declaration shadows a local variable [-Wshadow] 2840 | tcp_hash_fail("AO hash is required, but not found", | ^ /include/net/tcp_ao.h:153:23: note: expanded from macro 'tcp_hash_fail' 153 | const struct tcphdr *th = tcp_hdr(skb); \ | ^ /include/net/tcp.h:2805:23: note: previous declaration is here 2805 | const struct tcphdr *th = tcp_hdr(skb); | ^ /include/net/tcp.h:2846:4: warning: declaration shadows a local variable [-Wshadow]
Sparse:
drivers/net/ethernet/intel/idpf/idpf_main.c: note: in included file (through drivers/net/ethernet/intel/idpf/idpf_txrx.h, drivers/net/ethernet/intel/idpf/idpf.h): /include/net/tcp.h:2812:17: warning: symbol 'th' shadows an earlier one /include/net/tcp.h:2805:29: originally declared here /include/net/tcp.h:2820:25: warning: symbol 'th' shadows an earlier one /include/net/tcp.h:2805:29: originally declared here /include/net/tcp.h:2840:25: warning: symbol 'th' shadows an earlier one /include/net/tcp.h:2805:29: originally declared here /include/net/tcp.h:2846:25: warning: symbol 'th' shadows an earlier one /include/net/tcp.h:2805:29: originally declared here
Just use __UNIQUE_ID() for the variables declared inside tcp_hash_fail().
Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com> --- include/net/tcp_ao.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/include/net/tcp_ao.h b/include/net/tcp_ao.h index 471e177362b4..c5303c9c6f80 100644 --- a/include/net/tcp_ao.h +++ b/include/net/tcp_ao.h @@ -148,7 +148,7 @@ static inline bool tcp_hash_should_produce_warnings(void) return static_branch_tcp_md5() || static_branch_tcp_ao(); } -#define tcp_hash_fail(msg, family, skb, fmt, ...) \ +#define _tcp_hash_fail(msg, family, skb, th, hdr_flags, f, fmt, ...) \ do { \ const struct tcphdr *th = tcp_hdr(skb); \ char hdr_flags[6]; \ @@ -179,6 +179,10 @@ do { \ hdr_flags, ##__VA_ARGS__); \ } \ } while (0) +#define tcp_hash_fail(msg, family, skb, fmt, ...) \ + _tcp_hash_fail(msg, family, skb, __UNIQUE_ID(th_), \ + __UNIQUE_ID(hdr_flags_), __UNIQUE_ID(f_), fmt, \ + ##__VA_ARGS__) #ifdef CONFIG_TCP_AO /* TCP-AO structures and functions */ -- 2.44.0
| |