All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: netdev@vger.kernel.org, Johannes Berg <johannes.berg@intel.com>
Subject: Re: [RFC] networking: introduce and use skb_put_data()
Date: Thu, 15 Jun 2017 08:40:01 -0700	[thread overview]
Message-ID: <20170615084001.3fc5585c@xeon-e3> (raw)
In-Reply-To: <20170615071018.9529-1-johannes@sipsolutions.net>

On Thu, 15 Jun 2017 09:10:18 +0200
Johannes Berg <johannes@sipsolutions.net> wrote:

> From: Johannes Berg <johannes.berg@intel.com>
> 
> A common pattern with skb_put() is to just want to memcpy()
> some data into the new space, introduce skb_put_data() for
> this.
> 
> An spatch similar to the one for skb_put_zero() converts many
> of the places using it:
> 
>     @@
>     identifier p, p2;
>     expression len, skb, data;
>     type t, t2;
>     @@
>     (
>     -p = skb_put(skb, len);
>     +p = skb_put_data(skb, data, len);
>     |
>     -p = (t)skb_put(skb, len);
>     +p = skb_put_data(skb, data, len);
>     )
>     (
>     p2 = (t2)p;
>     -memcpy(p2, data, len);
>     |
>     -memcpy(p, data, len);
>     )
> 
>     @@
>     type t, t2;
>     identifier p, p2;
>     expression skb, data;
>     @@
>     t *p;
>     ...
>     (
>     -p = skb_put(skb, sizeof(t));
>     +p = skb_put_data(skb, data, sizeof(t));
>     |
>     -p = (t *)skb_put(skb, sizeof(t));
>     +p = skb_put_data(skb, data, sizeof(t));
>     )
>     (
>     p2 = (t2)p;
>     -memcpy(p2, data, sizeof(*p));
>     |
>     -memcpy(p, data, sizeof(*p));
>     )
> 
>     @@
>     expression skb, len, data;
>     @@
>     -memcpy(skb_put(skb, len), data, len);
>     +skb_put_data(skb, data, len);
> 
> (again, manually post-processed to retain some comments)
> 
> Signed-off-by: Johannes Berg <johannes.berg@intel.com>

LGTM

Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>

      reply	other threads:[~2017-06-15 15:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-15  7:10 [RFC] networking: introduce and use skb_put_data() Johannes Berg
2017-06-15 15:40 ` Stephen Hemminger [this message]

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=20170615084001.3fc5585c@xeon-e3 \
    --to=stephen@networkplumber.org \
    --cc=johannes.berg@intel.com \
    --cc=johannes@sipsolutions.net \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.