diff options
author | Johannes Berg <johannes.berg@intel.com> | 2017-06-16 15:29:19 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-06-16 18:48:35 +0300 |
commit | b080db585384b9f037e015c0c28d1ad33be41dfc (patch) | |
tree | ea9cc5c3161d776b948283a3d4f483cbf578e043 /drivers/usb/gadget/function | |
parent | 61f73d1ea4c68544b959228ead7ef5c021791b14 (diff) | |
download | linux-b080db585384b9f037e015c0c28d1ad33be41dfc.tar.xz |
networking: convert many more places to skb_put_zero()
There were many places that my previous spatch didn't find,
as pointed out by yuan linyu in various patches.
The following spatch found many more and also removes the
now unnecessary casts:
@@
identifier p, p2;
expression len;
expression skb;
type t, t2;
@@
(
-p = skb_put(skb, len);
+p = skb_put_zero(skb, len);
|
-p = (t)skb_put(skb, len);
+p = skb_put_zero(skb, len);
)
... when != p
(
p2 = (t2)p;
-memset(p2, 0, len);
|
-memset(p, 0, len);
)
@@
type t, t2;
identifier p, p2;
expression skb;
@@
t *p;
...
(
-p = skb_put(skb, sizeof(t));
+p = skb_put_zero(skb, sizeof(t));
|
-p = (t *)skb_put(skb, sizeof(t));
+p = skb_put_zero(skb, sizeof(t));
)
... when != p
(
p2 = (t2)p;
-memset(p2, 0, sizeof(*p));
|
-memset(p, 0, sizeof(*p));
)
@@
expression skb, len;
@@
-memset(skb_put(skb, len), 0, len);
+skb_put_zero(skb, len);
Apply it to the tree (with one manual fixup to keep the
comment in vxlan.c, which spatch removed.)
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/usb/gadget/function')
-rw-r--r-- | drivers/usb/gadget/function/f_ncm.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/function/f_ncm.c index 864819ff9a7d..2882c6d3ae66 100644 --- a/drivers/usb/gadget/function/f_ncm.c +++ b/drivers/usb/gadget/function/f_ncm.c @@ -1004,8 +1004,7 @@ static struct sk_buff *package_for_tx(struct f_ncm *ncm) } /* Insert NDP alignment. */ - ntb_iter = (void *) skb_put(skb2, ndp_pad); - memset(ntb_iter, 0, ndp_pad); + ntb_iter = skb_put_zero(skb2, ndp_pad); /* Copy NTB across. */ ntb_iter = (void *) skb_put(skb2, ncm->skb_tx_ndp->len); @@ -1014,8 +1013,7 @@ static struct sk_buff *package_for_tx(struct f_ncm *ncm) ncm->skb_tx_ndp = NULL; /* Insert zero'd datagram. */ - ntb_iter = (void *) skb_put(skb2, dgram_idx_len); - memset(ntb_iter, 0, dgram_idx_len); + ntb_iter = skb_put_zero(skb2, dgram_idx_len); return skb2; } @@ -1080,8 +1078,7 @@ static struct sk_buff *ncm_wrap_ntb(struct gether *port, goto err; ncm->skb_tx_data->dev = ncm->netdev; - ntb_data = (void *) skb_put(ncm->skb_tx_data, ncb_len); - memset(ntb_data, 0, ncb_len); + ntb_data = skb_put_zero(ncm->skb_tx_data, ncb_len); /* dwSignature */ put_unaligned_le32(opts->nth_sign, ntb_data); ntb_data += 2; @@ -1118,8 +1115,7 @@ static struct sk_buff *ncm_wrap_ntb(struct gether *port, HRTIMER_MODE_REL); /* Add the datagram position entries */ - ntb_ndp = (void *) skb_put(ncm->skb_tx_ndp, dgram_idx_len); - memset(ntb_ndp, 0, dgram_idx_len); + ntb_ndp = skb_put_zero(ncm->skb_tx_ndp, dgram_idx_len); ncb_len = ncm->skb_tx_data->len; dgram_pad = ALIGN(ncb_len, div) + rem - ncb_len; @@ -1132,8 +1128,7 @@ static struct sk_buff *ncm_wrap_ntb(struct gether *port, ncm->ndp_dgram_count++; /* Add the new data to the skb */ - ntb_data = (void *) skb_put(ncm->skb_tx_data, dgram_pad); - memset(ntb_data, 0, dgram_pad); + ntb_data = skb_put_zero(ncm->skb_tx_data, dgram_pad); ntb_data = (void *) skb_put(ncm->skb_tx_data, skb->len); memcpy(ntb_data, skb->data, skb->len); dev_consume_skb_any(skb); |