From: Justin Stitt <justinstitt@google.com>
To: Pablo Neira Ayuso <pablo@netfilter.org>,
Jozsef Kadlecsik <kadlec@netfilter.org>,
Florian Westphal <fw@strlen.de>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: Nathan Chancellor <nathan@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>,
Tom Rix <trix@redhat.com>,
netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev, Justin Stitt <justinstitt@google.com>
Subject: [PATCH] netfilter: xt_TPROXY: fix clang -Wformat warnings:
Date: Thu, 7 Jul 2022 12:17:45 -0700 [thread overview]
Message-ID: <20220707191745.840590-1-justinstitt@google.com> (raw)
When building with Clang we encounter these warnings:
| net/netfilter/xt_TPROXY.c:173:5: error: format specifies type 'unsigned
| char' but the argument has type 'int' [-Werror,-Wformat] tproto,
| &iph->saddr, ntohs(hp->source),
-
| net/netfilter/xt_TPROXY.c:181:4: error: format specifies type 'unsigned
| char' but the argument has type 'int' [-Werror,-Wformat] tproto,
| &iph->saddr, ntohs(hp->source),
The format specifier `%hhu` refers to a u8 while tproto is an int. In
this case we weren't losing any data because ipv6_find_hdr returns an
int but its return value (nexthdr) is a u8. This u8 gets widened to an
int when returned from ipv6_find_hdr and assigned to tproto. The
previous format specifier is functionally fine but still produces a
warning due to a type mismatch.
The fix is simply to listen to Clang and change `%hhu` to `%d` for both
instances of the warning.
Link: https://github.com/ClangBuiltLinux/linux/issues/378
Signed-off-by: Justin Stitt <justinstitt@google.com>
---
It should be noted that for this entire file to build without -Wformat
warnings you should apply this `ntohs` patch which fixed many, many
-Wformat warnings in the kernel.
https://lore.kernel.org/all/20220608223539.470472-1-justinstitt@google.com/
net/netfilter/xt_TPROXY.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/netfilter/xt_TPROXY.c b/net/netfilter/xt_TPROXY.c
index 459d0696c91a..5d74abffc94f 100644
--- a/net/netfilter/xt_TPROXY.c
+++ b/net/netfilter/xt_TPROXY.c
@@ -169,7 +169,7 @@ tproxy_tg6_v1(struct sk_buff *skb, const struct xt_action_param *par)
targets on the same rule yet */
skb->mark = (skb->mark & ~tgi->mark_mask) ^ tgi->mark_value;
- pr_debug("redirecting: proto %hhu %pI6:%hu -> %pI6:%hu, mark: %x\n",
+ pr_debug("redirecting: proto %d %pI6:%hu -> %pI6:%hu, mark: %x\n",
tproto, &iph->saddr, ntohs(hp->source),
laddr, ntohs(lport), skb->mark);
@@ -177,7 +177,7 @@ tproxy_tg6_v1(struct sk_buff *skb, const struct xt_action_param *par)
return NF_ACCEPT;
}
- pr_debug("no socket, dropping: proto %hhu %pI6:%hu -> %pI6:%hu, mark: %x\n",
+ pr_debug("no socket, dropping: proto %d %pI6:%hu -> %pI6:%hu, mark: %x\n",
tproto, &iph->saddr, ntohs(hp->source),
&iph->daddr, ntohs(hp->dest), skb->mark);
--
2.37.0.rc0.161.g10f37bed90-goog
next reply other threads:[~2022-07-07 19:18 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-07 19:17 Justin Stitt [this message]
2022-07-08 23:33 ` [PATCH] netfilter: xt_TPROXY: fix clang -Wformat warnings: Nick Desaulniers
2022-07-11 9:04 ` Pablo Neira Ayuso
2022-07-11 19:44 ` Justin Stitt
2022-07-12 8:40 ` Pablo Neira Ayuso
2022-07-12 18:34 ` [PATCH] netfilter: xt_TPROXY: remove pr_debug invocations Justin Stitt
2022-07-12 18:56 ` Nathan Chancellor
2022-07-12 20:38 ` Justin Stitt
2022-07-12 20:49 ` [PATCH v2] " Justin Stitt
2022-07-18 17:43 ` Justin Stitt
2022-07-18 21:38 ` Pablo Neira Ayuso
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=20220707191745.840590-1-justinstitt@google.com \
--to=justinstitt@google.com \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=kadlec@netfilter.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
--cc=trix@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;
as well as URLs for NNTP newsgroup(s).