Skip to content

Commit b080db5

Browse files
jmberg-inteldavem330
authored andcommitted
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>
1 parent 61f73d1 commit b080db5

49 files changed

Lines changed: 89 additions & 169 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎drivers/infiniband/hw/cxgb3/cxio_hal.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,7 @@ static int cxio_hal_clear_qp_ctx(struct cxio_rdev *rdev_p, u32 qpid)
142142
pr_debug("%s alloc_skb failed\n", __func__);
143143
return -ENOMEM;
144144
}
145-
wqe = (struct t3_modify_qp_wr *) skb_put(skb, sizeof(*wqe));
146-
memset(wqe, 0, sizeof(*wqe));
145+
wqe = skb_put_zero(skb, sizeof(*wqe));
147146
build_fw_riwrh((struct fw_riwrh *) wqe, T3_WR_QP_MOD,
148147
T3_COMPLETION_FLAG | T3_NOTIFY_FLAG, 0, qpid, 7,
149148
T3_SOPEOP);
@@ -561,8 +560,7 @@ static int cxio_hal_init_ctrl_qp(struct cxio_rdev *rdev_p)
561560
ctx1 |= ((u64) (V_EC_BASE_HI((u32) base_addr & 0xf) | V_EC_RESPQ(0) |
562561
V_EC_TYPE(0) | V_EC_GEN(1) |
563562
V_EC_UP_TOKEN(T3_CTL_QP_TID) | F_EC_VALID)) << 32;
564-
wqe = (struct t3_modify_qp_wr *) skb_put(skb, sizeof(*wqe));
565-
memset(wqe, 0, sizeof(*wqe));
563+
wqe = skb_put_zero(skb, sizeof(*wqe));
566564
build_fw_riwrh((struct fw_riwrh *) wqe, T3_WR_QP_MOD, 0, 0,
567565
T3_CTL_QP_TID, 7, T3_SOPEOP);
568566
wqe->flags = cpu_to_be32(MODQP_WRITE_EC);

‎drivers/infiniband/hw/cxgb3/iwch_cm.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,7 @@ static int send_abort(struct iwch_ep *ep, struct sk_buff *skb, gfp_t gfp)
417417
}
418418
skb->priority = CPL_PRIORITY_DATA;
419419
set_arp_failure_handler(skb, abort_arp_failure);
420-
req = (struct cpl_abort_req *) skb_put(skb, sizeof(*req));
421-
memset(req, 0, sizeof(*req));
420+
req = skb_put_zero(skb, sizeof(*req));
422421
req->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_OFLD_HOST_ABORT_CON_REQ));
423422
req->wr.wr_lo = htonl(V_WR_TID(ep->hwtid));
424423
OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_ABORT_REQ, ep->hwtid));

‎drivers/infiniband/hw/cxgb3/iwch_qp.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -670,8 +670,7 @@ int iwch_post_zb_read(struct iwch_ep *ep)
670670
pr_err("%s cannot send zb_read!!\n", __func__);
671671
return -ENOMEM;
672672
}
673-
wqe = (union t3_wr *)skb_put(skb, sizeof(struct t3_rdma_read_wr));
674-
memset(wqe, 0, sizeof(struct t3_rdma_read_wr));
673+
wqe = skb_put_zero(skb, sizeof(struct t3_rdma_read_wr));
675674
wqe->read.rdmaop = T3_READ_REQ;
676675
wqe->read.reserved[0] = 0;
677676
wqe->read.reserved[1] = 0;
@@ -702,8 +701,7 @@ int iwch_post_terminate(struct iwch_qp *qhp, struct respQ_msg_t *rsp_msg)
702701
pr_err("%s cannot send TERMINATE!\n", __func__);
703702
return -ENOMEM;
704703
}
705-
wqe = (union t3_wr *)skb_put(skb, 40);
706-
memset(wqe, 0, 40);
704+
wqe = skb_put_zero(skb, 40);
707705
wqe->send.rdmaop = T3_TERMINATE;
708706

709707
/* immediate data length */

‎drivers/infiniband/hw/cxgb4/cm.c‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -927,8 +927,7 @@ static int send_mpa_req(struct c4iw_ep *ep, struct sk_buff *skb,
927927
}
928928
set_wr_txq(skb, CPL_PRIORITY_DATA, ep->txq_idx);
929929

930-
req = (struct fw_ofld_tx_data_wr *)skb_put(skb, wrlen);
931-
memset(req, 0, wrlen);
930+
req = skb_put_zero(skb, wrlen);
932931
req->op_to_immdlen = cpu_to_be32(
933932
FW_WR_OP_V(FW_OFLD_TX_DATA_WR) |
934933
FW_WR_COMPL_F |
@@ -1034,8 +1033,7 @@ static int send_mpa_reject(struct c4iw_ep *ep, const void *pdata, u8 plen)
10341033
}
10351034
set_wr_txq(skb, CPL_PRIORITY_DATA, ep->txq_idx);
10361035

1037-
req = (struct fw_ofld_tx_data_wr *)skb_put(skb, wrlen);
1038-
memset(req, 0, wrlen);
1036+
req = skb_put_zero(skb, wrlen);
10391037
req->op_to_immdlen = cpu_to_be32(
10401038
FW_WR_OP_V(FW_OFLD_TX_DATA_WR) |
10411039
FW_WR_COMPL_F |
@@ -1115,8 +1113,7 @@ static int send_mpa_reply(struct c4iw_ep *ep, const void *pdata, u8 plen)
11151113
}
11161114
set_wr_txq(skb, CPL_PRIORITY_DATA, ep->txq_idx);
11171115

1118-
req = (struct fw_ofld_tx_data_wr *) skb_put(skb, wrlen);
1119-
memset(req, 0, wrlen);
1116+
req = skb_put_zero(skb, wrlen);
11201117
req->op_to_immdlen = cpu_to_be32(
11211118
FW_WR_OP_V(FW_OFLD_TX_DATA_WR) |
11221119
FW_WR_COMPL_F |

‎drivers/net/ethernet/mellanox/mlx5/core/en_selftest.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ static struct sk_buff *mlx5e_test_get_udp_skb(struct mlx5e_priv *priv)
172172
mlxh->magic = cpu_to_be64(MLX5E_TEST_MAGIC);
173173
strlcpy(mlxh->text, mlx5e_test_text, sizeof(mlxh->text));
174174
datalen -= sizeof(*mlxh);
175-
memset(skb_put(skb, datalen), 0, datalen);
175+
skb_put_zero(skb, datalen);
176176

177177
skb->csum = 0;
178178
skb->ip_summed = CHECKSUM_PARTIAL;

‎drivers/net/usb/cdc_ncm.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@ static void cdc_ncm_align_tail(struct sk_buff *skb, size_t modulus, size_t remai
10171017
if (skb->len + align > max)
10181018
align = max - skb->len;
10191019
if (align && skb_tailroom(skb) >= align)
1020-
memset(skb_put(skb, align), 0, align);
1020+
skb_put_zero(skb, align);
10211021
}
10221022

10231023
/* return a pointer to a valid struct usb_cdc_ncm_ndp16 of type sign, possibly
@@ -1247,7 +1247,7 @@ cdc_ncm_fill_tx_frame(struct usbnet *dev, struct sk_buff *skb, __le32 sign)
12471247
if (!(dev->driver_info->flags & FLAG_SEND_ZLP) &&
12481248
skb_out->len > ctx->min_tx_pkt) {
12491249
padding_count = ctx->tx_max - skb_out->len;
1250-
memset(skb_put(skb_out, padding_count), 0, padding_count);
1250+
skb_put_zero(skb_out, padding_count);
12511251
} else if (skb_out->len < ctx->tx_max &&
12521252
(skb_out->len % dev->maxpacket) == 0) {
12531253
*skb_put(skb_out, 1) = 0; /* force short packet */

‎drivers/net/usb/kalmia.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ kalmia_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
217217
remainder = skb->len % KALMIA_ALIGN_SIZE;
218218
if (remainder > 0) {
219219
padlen = KALMIA_ALIGN_SIZE - remainder;
220-
memset(skb_put(skb, padlen), 0, padlen);
220+
skb_put_zero(skb, padlen);
221221
}
222222

223223
netdev_dbg(dev->net,

‎drivers/net/vxlan.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,10 +1584,8 @@ static struct sk_buff *vxlan_na_create(struct sk_buff *request,
15841584
skb_pull(reply, sizeof(struct ipv6hdr));
15851585
skb_reset_transport_header(reply);
15861586

1587-
na = (struct nd_msg *)skb_put(reply, sizeof(*na) + na_olen);
1588-
15891587
/* Neighbor Advertisement */
1590-
memset(na, 0, sizeof(*na)+na_olen);
1588+
na = skb_put_zero(reply, sizeof(*na) + na_olen);
15911589
na->icmph.icmp6_type = NDISC_NEIGHBOUR_ADVERTISEMENT;
15921590
na->icmph.icmp6_router = isrouter;
15931591
na->icmph.icmp6_override = 1;

‎drivers/net/wireless/ath/ath9k/channel.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,8 +1526,7 @@ void ath9k_beacon_add_noa(struct ath_softc *sc, struct ath_vif *avp,
15261526
hdr[1] = sizeof(noa_ie_hdr) + noa_len - 2;
15271527
hdr[7] = noa_len;
15281528

1529-
noa = (void *) skb_put(skb, noa_len);
1530-
memset(noa, 0, noa_len);
1529+
noa = skb_put_zero(skb, noa_len);
15311530

15321531
noa->index = avp->noa_index;
15331532
noa->oppps_ctwindow = ath9k_get_ctwin(sc, avp);

‎drivers/net/wireless/intersil/hostap/hostap_ap.c‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -998,12 +998,10 @@ static void prism2_send_mgmt(struct net_device *dev,
998998

999999
fc = type_subtype;
10001000
hdrlen = hostap_80211_get_hdrlen(cpu_to_le16(type_subtype));
1001-
hdr = (struct ieee80211_hdr *) skb_put(skb, hdrlen);
1001+
hdr = skb_put_zero(skb, hdrlen);
10021002
if (body)
10031003
memcpy(skb_put(skb, body_len), body, body_len);
10041004

1005-
memset(hdr, 0, hdrlen);
1006-
10071005
/* FIX: ctrl::ack sending used special HFA384X_TX_CTRL_802_11
10081006
* tx_control instead of using local->tx_control */
10091007

@@ -1325,8 +1323,7 @@ static char * ap_auth_make_challenge(struct ap_data *ap)
13251323
}
13261324

13271325
skb_reserve(skb, ap->crypt->extra_mpdu_prefix_len);
1328-
memset(skb_put(skb, WLAN_AUTH_CHALLENGE_LEN), 0,
1329-
WLAN_AUTH_CHALLENGE_LEN);
1326+
skb_put_zero(skb, WLAN_AUTH_CHALLENGE_LEN);
13301327
if (ap->crypt->encrypt_mpdu(skb, 0, ap->crypt_priv)) {
13311328
dev_kfree_skb(skb);
13321329
kfree(tmpbuf);

0 commit comments

Comments
 (0)