From: Johannes Berg <johannes@sipsolutions.net>
To: YUAN Linyu <Linyu.Yuan@alcatel-sbell.com.cn>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: [RFC] networking: convert many more places to skb_put_zero()
Date: Thu, 15 Jun 2017 08:57:42 +0200 [thread overview]
Message-ID: <1497509862.2518.1.camel@sipsolutions.net> (raw)
In-Reply-To: <8729016553E3654398EA69218DA29EEF15BC8D22@cnshjmbx02>
On Thu, 2017-06-15 at 00:23 +0000, YUAN Linyu wrote:
> Hi,
> Indeed, it find more.
> Compare with my patch, still lost pattern like below,
> 1. sctp and openvswitch
> --- a/net/sctp/output.c
> +++ b/net/sctp/output.c
> @@ -463,7 +463,7 @@ static int sctp_packet_pack(struct sctp_packet
> *packet,
>
> padding = SCTP_PAD4(chunk->skb->len) -
> chunk->skb->len;
> if (padding)
> - memset(skb_put(chunk->skb, padding),
> 0, padding);
> + skb_put_zero(chunk->skb, padding);
Yep, good catch, this finds 18 instances thereof:
@@
expression skb, len;
@@
-memset(skb_put(skb, len), 0, len);
+skb_put_zero(skb, len);
> --- a/net/dsa/tag_trailer.c
> +++ b/net/dsa/tag_trailer.c
> @@ -43,8 +43,7 @@ static struct sk_buff *trailer_xmit(struct sk_buff
> *skb, struct net_device *dev)
> kfree_skb(skb);
>
> if (padlen) {
> - u8 *pad = skb_put(nskb, padlen);
> - memset(pad, 0, padlen);
> + skb_put_zero(nskb, padlen);
I'd have thought it finds this, but indeed it doesn't; there's only one
instances this changes though:
@@
type t;
expression skb, len;
identifier p;
@@
t *p
- = skb_put(skb, len);
+ = skb_put_zero(skb, len);
-memset(p, 0, len);
and it can't figure out that it should remove the variable, without
much more work that's not really worth it for one instance :)
johannes
next prev parent reply other threads:[~2017-06-15 6:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-14 20:17 [RFC] networking: convert many more places to skb_put_zero() Johannes Berg
2017-06-15 0:23 ` YUAN Linyu
2017-06-15 6:57 ` Johannes Berg [this message]
2017-06-15 7:05 ` YUAN Linyu
2017-06-15 7:11 ` Johannes Berg
2017-06-15 7:20 ` YUAN Linyu
2017-06-15 7:45 ` Johannes Berg
2017-06-15 7:47 ` YUAN Linyu
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=1497509862.2518.1.camel@sipsolutions.net \
--to=johannes@sipsolutions.net \
--cc=Linyu.Yuan@alcatel-sbell.com.cn \
--cc=netdev@vger.kernel.org \
/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).