* [PATCH] skbuff: fix compilation warnings in skb_dump()
@ 2019-07-16 14:54 Qian Cai
2019-07-16 15:04 ` Willem de Bruijn
0 siblings, 1 reply; 3+ messages in thread
From: Qian Cai @ 2019-07-16 14:54 UTC (permalink / raw)
To: davem; +Cc: willemb, clang-built-linux, netdev, linux-kernel, Qian Cai
The commit 6413139dfc64 ("skbuff: increase verbosity when dumping skb
data") introduced a few compilation warnings.
net/core/skbuff.c:766:32: warning: format specifies type 'unsigned
short' but the argument has type 'unsigned int' [-Wformat]
level, sk->sk_family, sk->sk_type,
sk->sk_protocol);
^~~~~~~~~~~
net/core/skbuff.c:766:45: warning: format specifies type 'unsigned
short' but the argument has type 'unsigned int' [-Wformat]
level, sk->sk_family, sk->sk_type,
sk->sk_protocol);
^~~~~~~~~~~~~~~
Fix them by using the proper types, and also fix some checkpatch
warnings by using pr_info().
WARNING: printk() should include KERN_<LEVEL> facility level
+ printk("%ssk family=%hu type=%u proto=%u\n",
Fixes: 6413139dfc64 ("skbuff: increase verbosity when dumping skb data")
Signed-off-by: Qian Cai <cai@lca.pw>
---
net/core/skbuff.c | 44 ++++++++++++++++++++++----------------------
1 file changed, 22 insertions(+), 22 deletions(-)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 6f1e31f674a3..fa1e78f7bb96 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -740,30 +740,30 @@ void skb_dump(const char *level, const struct sk_buff *skb, bool full_pkt)
has_mac = skb_mac_header_was_set(skb);
has_trans = skb_transport_header_was_set(skb);
- printk("%sskb len=%u headroom=%u headlen=%u tailroom=%u\n"
- "mac=(%d,%d) net=(%d,%d) trans=%d\n"
- "shinfo(txflags=%u nr_frags=%u gso(size=%hu type=%u segs=%hu))\n"
- "csum(0x%x ip_summed=%u complete_sw=%u valid=%u level=%u)\n"
- "hash(0x%x sw=%u l4=%u) proto=0x%04x pkttype=%u iif=%d\n",
- level, skb->len, headroom, skb_headlen(skb), tailroom,
- has_mac ? skb->mac_header : -1,
- has_mac ? skb_mac_header_len(skb) : -1,
- skb->network_header,
- has_trans ? skb_network_header_len(skb) : -1,
- has_trans ? skb->transport_header : -1,
- sh->tx_flags, sh->nr_frags,
- sh->gso_size, sh->gso_type, sh->gso_segs,
- skb->csum, skb->ip_summed, skb->csum_complete_sw,
- skb->csum_valid, skb->csum_level,
- skb->hash, skb->sw_hash, skb->l4_hash,
- ntohs(skb->protocol), skb->pkt_type, skb->skb_iif);
+ pr_info("%sskb len=%u headroom=%u headlen=%u tailroom=%u\n"
+ "mac=(%d,%d) net=(%d,%d) trans=%d\n"
+ "shinfo(txflags=%u nr_frags=%u gso(size=%hu type=%u segs=%hu))\n"
+ "csum(0x%x ip_summed=%u complete_sw=%u valid=%u level=%u)\n"
+ "hash(0x%x sw=%u l4=%u) proto=0x%04x pkttype=%u iif=%d\n",
+ level, skb->len, headroom, skb_headlen(skb), tailroom,
+ has_mac ? skb->mac_header : -1,
+ has_mac ? skb_mac_header_len(skb) : -1,
+ skb->network_header,
+ has_trans ? skb_network_header_len(skb) : -1,
+ has_trans ? skb->transport_header : -1,
+ sh->tx_flags, sh->nr_frags,
+ sh->gso_size, sh->gso_type, sh->gso_segs,
+ skb->csum, skb->ip_summed, skb->csum_complete_sw,
+ skb->csum_valid, skb->csum_level,
+ skb->hash, skb->sw_hash, skb->l4_hash,
+ ntohs(skb->protocol), skb->pkt_type, skb->skb_iif);
if (dev)
- printk("%sdev name=%s feat=0x%pNF\n",
- level, dev->name, &dev->features);
+ pr_info("%sdev name=%s feat=0x%pNF\n",
+ level, dev->name, &dev->features);
if (sk)
- printk("%ssk family=%hu type=%hu proto=%hu\n",
- level, sk->sk_family, sk->sk_type, sk->sk_protocol);
+ pr_info("%ssk family=%hu type=%u proto=%u\n",
+ level, sk->sk_family, sk->sk_type, sk->sk_protocol);
if (full_pkt && headroom)
print_hex_dump(level, "skb headroom: ", DUMP_PREFIX_OFFSET,
@@ -801,7 +801,7 @@ void skb_dump(const char *level, const struct sk_buff *skb, bool full_pkt)
}
if (full_pkt && skb_has_frag_list(skb)) {
- printk("skb fraglist:\n");
+ pr_info("skb fraglist:\n");
skb_walk_frags(skb, list_skb)
skb_dump(level, list_skb, true);
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] skbuff: fix compilation warnings in skb_dump()
2019-07-16 14:54 [PATCH] skbuff: fix compilation warnings in skb_dump() Qian Cai
@ 2019-07-16 15:04 ` Willem de Bruijn
2019-07-17 3:06 ` Joe Perches
0 siblings, 1 reply; 3+ messages in thread
From: Willem de Bruijn @ 2019-07-16 15:04 UTC (permalink / raw)
To: Qian Cai
Cc: David Miller, Willem de Bruijn, clang-built-linux,
Network Development, LKML
On Tue, Jul 16, 2019 at 4:56 PM Qian Cai <cai@lca.pw> wrote:
>
> The commit 6413139dfc64 ("skbuff: increase verbosity when dumping skb
> data") introduced a few compilation warnings.
>
> net/core/skbuff.c:766:32: warning: format specifies type 'unsigned
> short' but the argument has type 'unsigned int' [-Wformat]
> level, sk->sk_family, sk->sk_type,
> sk->sk_protocol);
> ^~~~~~~~~~~
> net/core/skbuff.c:766:45: warning: format specifies type 'unsigned
> short' but the argument has type 'unsigned int' [-Wformat]
> level, sk->sk_family, sk->sk_type,
> sk->sk_protocol);
> ^~~~~~~~~~~~~~~
Ah, I looked at sk_family (skc_family), which is type unsigned short.
But sk_type and sk_protocol are defined as
unsigned int sk_padding : 1,
sk_kern_sock : 1,
sk_no_check_tx : 1,
sk_no_check_rx : 1,
sk_userlocks : 4,
sk_protocol : 8,
sk_type : 16;
So %u is indeed needed instead of %hu.
> Fix them by using the proper types, and also fix some checkpatch
> warnings by using pr_info().
>
> WARNING: printk() should include KERN_<LEVEL> facility level
> + printk("%ssk family=%hu type=%u proto=%u\n",
Converting printk to pr_info lowers all levels to KERN_INFO.
skb_dump takes an explicit parameter level to be able to log at
KERN_ERR or KERN_WARNING
I would like to avoid those checkpatch warnings, but this is not the
right approach.
> Fixes: 6413139dfc64 ("skbuff: increase verbosity when dumping skb data")
Thanks. For a v2, please mark the target branch, as [PATCH net v2].
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] skbuff: fix compilation warnings in skb_dump()
2019-07-16 15:04 ` Willem de Bruijn
@ 2019-07-17 3:06 ` Joe Perches
0 siblings, 0 replies; 3+ messages in thread
From: Joe Perches @ 2019-07-17 3:06 UTC (permalink / raw)
To: Willem de Bruijn, Qian Cai
Cc: David Miller, Willem de Bruijn, clang-built-linux,
Network Development, LKML
On Tue, 2019-07-16 at 17:04 +0200, Willem de Bruijn wrote:
> On Tue, Jul 16, 2019 at 4:56 PM Qian Cai <cai@lca.pw> wrote:
> > Fix them by using the proper types, and also fix some checkpatch
> > warnings by using pr_info().
> >
> > WARNING: printk() should include KERN_<LEVEL> facility level
> > + printk("%ssk family=%hu type=%u proto=%u\n",
>
> Converting printk to pr_info lowers all levels to KERN_INFO.
>
> skb_dump takes an explicit parameter level to be able to log at
> KERN_ERR or KERN_WARNING
>
> I would like to avoid those checkpatch warnings, but this is not the
> right approach.
Just ignore checkpatch when it doesn't know that
the printk actually includes a KERN_<LEVEL> via
"%s...", level
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-07-17 3:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-16 14:54 [PATCH] skbuff: fix compilation warnings in skb_dump() Qian Cai
2019-07-16 15:04 ` Willem de Bruijn
2019-07-17 3:06 ` Joe Perches
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).