Commit aa9f979c authored by Johannes Berg's avatar Johannes Berg Committed by David S. Miller

networking: use skb_put_zero()

Use the recently introduced helper to replace the pattern of
skb_put() && memset(), this transformation was done with the
following spatch:

@@
identifier p;
expression len;
expression skb;
@@
-p = skb_put(skb, len);
-memset(p, 0, len);
+p = skb_put_zero(skb, len);
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0e74008b
...@@ -1218,8 +1218,7 @@ static void bmac_reset_and_enable(struct net_device *dev) ...@@ -1218,8 +1218,7 @@ static void bmac_reset_and_enable(struct net_device *dev)
*/ */
skb = netdev_alloc_skb(dev, ETHERMINPACKET); skb = netdev_alloc_skb(dev, ETHERMINPACKET);
if (skb != NULL) { if (skb != NULL) {
data = skb_put(skb, ETHERMINPACKET); data = skb_put_zero(skb, ETHERMINPACKET);
memset(data, 0, ETHERMINPACKET);
memcpy(data, dev->dev_addr, ETH_ALEN); memcpy(data, dev->dev_addr, ETH_ALEN);
memcpy(data + ETH_ALEN, dev->dev_addr, ETH_ALEN); memcpy(data + ETH_ALEN, dev->dev_addr, ETH_ALEN);
bmac_transmit_packet(skb, dev); bmac_transmit_packet(skb, dev);
......
...@@ -609,8 +609,7 @@ static int bcm_enet_start_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -609,8 +609,7 @@ static int bcm_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
dev_kfree_skb(skb); dev_kfree_skb(skb);
skb = nskb; skb = nskb;
} }
data = skb_put(skb, needed); data = skb_put_zero(skb, needed);
memset(data, 0, needed);
} }
/* point to the next available desc */ /* point to the next available desc */
......
...@@ -719,8 +719,7 @@ qcaspi_netdev_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -719,8 +719,7 @@ qcaspi_netdev_xmit(struct sk_buff *skb, struct net_device *dev)
qcafrm_create_header(ptmp, frame_len); qcafrm_create_header(ptmp, frame_len);
if (pad_len) { if (pad_len) {
ptmp = skb_put(skb, pad_len); ptmp = skb_put_zero(skb, pad_len);
memset(ptmp, 0, pad_len);
} }
ptmp = skb_put(skb, QCAFRM_FOOTER_LEN); ptmp = skb_put(skb, QCAFRM_FOOTER_LEN);
......
...@@ -853,8 +853,8 @@ int mwifiex_send_tdls_action_frame(struct mwifiex_private *priv, const u8 *peer, ...@@ -853,8 +853,8 @@ int mwifiex_send_tdls_action_frame(struct mwifiex_private *priv, const u8 *peer,
pkt_type = PKT_TYPE_MGMT; pkt_type = PKT_TYPE_MGMT;
tx_control = 0; tx_control = 0;
pos = skb_put(skb, MWIFIEX_MGMT_FRAME_HEADER_SIZE + sizeof(pkt_len)); pos = skb_put_zero(skb,
memset(pos, 0, MWIFIEX_MGMT_FRAME_HEADER_SIZE + sizeof(pkt_len)); MWIFIEX_MGMT_FRAME_HEADER_SIZE + sizeof(pkt_len));
memcpy(pos, &pkt_type, sizeof(pkt_type)); memcpy(pos, &pkt_type, sizeof(pkt_type));
memcpy(pos + sizeof(pkt_type), &tx_control, sizeof(tx_control)); memcpy(pos + sizeof(pkt_type), &tx_control, sizeof(tx_control));
......
...@@ -1043,8 +1043,7 @@ static struct sk_buff *pn533_alloc_poll_tg_frame(struct pn533 *dev) ...@@ -1043,8 +1043,7 @@ static struct sk_buff *pn533_alloc_poll_tg_frame(struct pn533 *dev)
get_random_bytes(felica + 2, 6); get_random_bytes(felica + 2, 6);
/* NFCID3 */ /* NFCID3 */
nfcid3 = skb_put(skb, 10); nfcid3 = skb_put_zero(skb, 10);
memset(nfcid3, 0, 10);
memcpy(nfcid3, felica, 8); memcpy(nfcid3, felica, 8);
/* General bytes */ /* General bytes */
......
...@@ -400,8 +400,7 @@ void *__nla_reserve_nohdr(struct sk_buff *skb, int attrlen) ...@@ -400,8 +400,7 @@ void *__nla_reserve_nohdr(struct sk_buff *skb, int attrlen)
{ {
void *start; void *start;
start = skb_put(skb, NLA_ALIGN(attrlen)); start = skb_put_zero(skb, NLA_ALIGN(attrlen));
memset(start, 0, NLA_ALIGN(attrlen));
return start; return start;
} }
......
...@@ -1296,8 +1296,7 @@ struct sctp_chunk *sctp_make_auth(const struct sctp_association *asoc) ...@@ -1296,8 +1296,7 @@ struct sctp_chunk *sctp_make_auth(const struct sctp_association *asoc)
retval->subh.auth_hdr = sctp_addto_chunk(retval, sizeof(sctp_authhdr_t), retval->subh.auth_hdr = sctp_addto_chunk(retval, sizeof(sctp_authhdr_t),
&auth_hdr); &auth_hdr);
hmac = skb_put(retval->skb, hmac_desc->hmac_len); hmac = skb_put_zero(retval->skb, hmac_desc->hmac_len);
memset(hmac, 0, hmac_desc->hmac_len);
/* Adjust the chunk header to include the empty MAC */ /* Adjust the chunk header to include the empty MAC */
retval->chunk_hdr->length = retval->chunk_hdr->length =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment