[PATCH] netfilter: conntrack: fix -Wformat

From: Nick Desaulniers
Date: Sat Nov 07 2020 - 02:56:33 EST


Clang is more aggressive about -Wformat warnings when the format flag
specifies a type smaller than the parameter. Fixes 8 instances of:

warning: format specifies type 'unsigned short' but the argument has
type 'int' [-Wformat]

Link: https://github.com/ClangBuiltLinux/linux/issues/378
Signed-off-by: Nick Desaulniers <ndesaulniers@xxxxxxxxxx>
---
net/netfilter/nf_conntrack_standalone.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
index 46c5557c1fec..c5aa45c38eb2 100644
--- a/net/netfilter/nf_conntrack_standalone.c
+++ b/net/netfilter/nf_conntrack_standalone.c
@@ -50,38 +50,38 @@ print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple,

switch (l4proto->l4proto) {
case IPPROTO_ICMP:
- seq_printf(s, "type=%u code=%u id=%u ",
+ seq_printf(s, "type=%u code=%u id=%hu ",
tuple->dst.u.icmp.type,
tuple->dst.u.icmp.code,
- ntohs(tuple->src.u.icmp.id));
+ (__be16)ntohs(tuple->src.u.icmp.id));
break;
case IPPROTO_TCP:
seq_printf(s, "sport=%hu dport=%hu ",
- ntohs(tuple->src.u.tcp.port),
- ntohs(tuple->dst.u.tcp.port));
+ (__be16)ntohs(tuple->src.u.tcp.port),
+ (__be16)ntohs(tuple->dst.u.tcp.port));
break;
case IPPROTO_UDPLITE:
case IPPROTO_UDP:
seq_printf(s, "sport=%hu dport=%hu ",
- ntohs(tuple->src.u.udp.port),
- ntohs(tuple->dst.u.udp.port));
+ (__be16)ntohs(tuple->src.u.udp.port),
+ (__be16)ntohs(tuple->dst.u.udp.port));

break;
case IPPROTO_DCCP:
seq_printf(s, "sport=%hu dport=%hu ",
- ntohs(tuple->src.u.dccp.port),
- ntohs(tuple->dst.u.dccp.port));
+ (__be16)ntohs(tuple->src.u.dccp.port),
+ (__be16)ntohs(tuple->dst.u.dccp.port));
break;
case IPPROTO_SCTP:
seq_printf(s, "sport=%hu dport=%hu ",
- ntohs(tuple->src.u.sctp.port),
- ntohs(tuple->dst.u.sctp.port));
+ (__be16)ntohs(tuple->src.u.sctp.port),
+ (__be16)ntohs(tuple->dst.u.sctp.port));
break;
case IPPROTO_ICMPV6:
- seq_printf(s, "type=%u code=%u id=%u ",
+ seq_printf(s, "type=%u code=%u id=%hu ",
tuple->dst.u.icmp.type,
tuple->dst.u.icmp.code,
- ntohs(tuple->src.u.icmp.id));
+ (__be16)ntohs(tuple->src.u.icmp.id));
break;
case IPPROTO_GRE:
seq_printf(s, "srckey=0x%x dstkey=0x%x ",
--
2.29.2.222.g5d2a92d10f8-goog