mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alexander Lobakin <aleksander.lobakin@intel.com>
To: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Alexander Lobakin <aleksander.lobakin@intel.com>,
	Dmitry Safonov <0x7f454c46@gmail.com>,
	Heiner Kallweit <hkallweit1@gmail.com>,
	nex.sw.ncis.osdt.itp.upstreaming@intel.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
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	[thread overview]
Message-ID: <20240329170000.3241460-2-aleksander.lobakin@intel.com> (raw)
In-Reply-To: <20240329170000.3241460-1-aleksander.lobakin@intel.com>

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


  reply	other threads:[~2024-03-29 17:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-29 16:59 [PATCH net-next 0/2] net: fix variable shadowing spam from headers Alexander Lobakin
2024-03-29 16:59 ` Alexander Lobakin [this message]
2024-03-29 17:00 ` [PATCH net-next 2/2] netdev_queues: fix -Wshadow / Sparse shadow warnings throughout the file Alexander Lobakin
2024-03-29 20:18   ` Jakub Kicinski
2024-03-29 20:18     ` Jakub Kicinski
2024-03-29 20:53     ` Jakub Kicinski
2024-03-29 20:53       ` Jakub Kicinski
2024-04-02 11:53       ` Alexander Lobakin
2024-04-02 12:45         ` Eric Dumazet
2024-04-02 15:53           ` Alexander Lobakin
2024-04-02 16:48             ` Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240329170000.3241460-2-aleksander.lobakin@intel.com \
    --to=aleksander.lobakin@intel.com \
    --cc=0x7f454c46@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nex.sw.ncis.osdt.itp.upstreaming@intel.com \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®