From: Arnd Bergmann <arnd@kernel.org>
To: linux-kernel@vger.kernel.org, Eric Dumazet <edumazet@google.com>,
"David S. Miller" <davem@davemloft.net>,
David Ahern <dsahern@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Nathan Chancellor <nathan@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
Nick Desaulniers <ndesaulniers@google.com>,
Bill Wendling <morbo@google.com>,
Justin Stitt <justinstitt@google.com>,
Dmitry Safonov <0x7f454c46@gmail.com>,
Neal Cardwell <ncardwell@google.com>,
"mfreemon@cloudflare.com" <mfreemon@cloudflare.com>,
Yan Zhai <yan@cloudflare.com>,
netdev@vger.kernel.org, llvm@lists.linux.dev
Subject: [PATCH 5/9] ipv4: tcp_output: avoid warning about NET_ADD_STATS
Date: Thu, 28 Mar 2024 15:30:43 +0100 [thread overview]
Message-ID: <20240328143051.1069575-6-arnd@kernel.org> (raw)
In-Reply-To: <20240328143051.1069575-1-arnd@kernel.org>
From: Arnd Bergmann <arnd@arndb.de>
Clang warns about a range check in percpu_add_op() being impossible
to hit for an u8 variable:
net/ipv4/tcp_output.c:188:3: error: result of comparison of constant -1 with expression of type 'u8' (aka 'unsigned char') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
NET_ADD_STATS(sock_net(sk), LINUX_MIB_TCPACKCOMPRESSED,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/net/ip.h:291:41: note: expanded from macro 'NET_ADD_STATS'
#define NET_ADD_STATS(net, field, adnd) SNMP_ADD_STATS((net)->mib.net_statistics, field, adnd)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/net/snmp.h:143:4: note: expanded from macro 'SNMP_ADD_STATS'
this_cpu_add(mib->mibs[field], addend)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/percpu-defs.h:509:33: note: expanded from macro 'this_cpu_add'
#define this_cpu_add(pcp, val) __pcpu_size_call(this_cpu_add_, pcp, val)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: (skipping 1 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
<scratch space>:187:1: note: expanded from here
this_cpu_add_8
^
arch/x86/include/asm/percpu.h:326:35: note: expanded from macro 'this_cpu_add_8'
#define this_cpu_add_8(pcp, val) percpu_add_op(8, volatile, (pcp), val)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/x86/include/asm/percpu.h:127:31: note: expanded from macro 'percpu_add_op'
((val) == 1 || (val) == -1)) ? \
~~~~~ ^ ~~
Avoid this warning with a cast to a signed 'int'.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
net/ipv4/tcp_output.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index e3167ad96567..dbe54fceee08 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -183,7 +183,7 @@ static inline void tcp_event_ack_sent(struct sock *sk, u32 rcv_nxt)
if (unlikely(tp->compressed_ack)) {
NET_ADD_STATS(sock_net(sk), LINUX_MIB_TCPACKCOMPRESSED,
- tp->compressed_ack);
+ (int)tp->compressed_ack);
tp->compressed_ack = 0;
if (hrtimer_try_to_cancel(&tp->compressed_ack_timer) == 1)
__sock_put(sk);
--
2.39.2
next prev parent reply other threads:[~2024-03-28 14:31 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-28 14:30 [PATCH 0/9] address remaining -Wtautological-constant-out-of-range-compare Arnd Bergmann
2024-03-28 14:30 ` [PATCH 2/9] libceph: avoid clang out-of-range warning Arnd Bergmann
2024-03-28 22:53 ` Justin Stitt
2024-03-29 0:06 ` Xiubo Li
2024-03-28 14:30 ` Arnd Bergmann [this message]
2024-03-28 14:38 ` [PATCH 5/9] ipv4: tcp_output: avoid warning about NET_ADD_STATS Eric Dumazet
2024-03-28 16:39 ` Arnd Bergmann
2024-03-28 14:30 ` [PATCH 8/9] mlx5: stop warning for 64KB pages Arnd Bergmann
2024-03-28 15:37 ` Maxim Mikityanskiy
2024-03-28 22:09 ` Justin Stitt
2024-03-28 22:21 ` Arnd Bergmann
2024-03-28 22:39 ` Tariq Toukan
2024-03-29 20:00 ` [PATCH 0/9] address remaining -Wtautological-constant-out-of-range-compare patchwork-bot+netdevbpf
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=20240328143051.1069575-6-arnd@kernel.org \
--to=arnd@kernel.org \
--cc=0x7f454c46@gmail.com \
--cc=arnd@arndb.de \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=justinstitt@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=mfreemon@cloudflare.com \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=ncardwell@google.com \
--cc=ndesaulniers@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=yan@cloudflare.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;
as well as URLs for NNTP newsgroup(s).