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>
This commit is contained in:
committed by
David S. Miller
parent
61f73d1ea4
commit
b080db5853
@@ -213,8 +213,7 @@ static void ieee80211_send_addba_resp(struct ieee80211_sub_if_data *sdata, u8 *d
|
||||
return;
|
||||
|
||||
skb_reserve(skb, local->hw.extra_tx_headroom);
|
||||
mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24);
|
||||
memset(mgmt, 0, 24);
|
||||
mgmt = skb_put_zero(skb, 24);
|
||||
memcpy(mgmt->da, da, ETH_ALEN);
|
||||
memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
|
||||
if (sdata->vif.type == NL80211_IFTYPE_AP ||
|
||||
|
||||
@@ -76,8 +76,7 @@ static void ieee80211_send_addba_request(struct ieee80211_sub_if_data *sdata,
|
||||
return;
|
||||
|
||||
skb_reserve(skb, local->hw.extra_tx_headroom);
|
||||
mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24);
|
||||
memset(mgmt, 0, 24);
|
||||
mgmt = skb_put_zero(skb, 24);
|
||||
memcpy(mgmt->da, da, ETH_ALEN);
|
||||
memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
|
||||
if (sdata->vif.type == NL80211_IFTYPE_AP ||
|
||||
@@ -125,8 +124,7 @@ void ieee80211_send_bar(struct ieee80211_vif *vif, u8 *ra, u16 tid, u16 ssn)
|
||||
return;
|
||||
|
||||
skb_reserve(skb, local->hw.extra_tx_headroom);
|
||||
bar = (struct ieee80211_bar *)skb_put(skb, sizeof(*bar));
|
||||
memset(bar, 0, sizeof(*bar));
|
||||
bar = skb_put_zero(skb, sizeof(*bar));
|
||||
bar->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL |
|
||||
IEEE80211_STYPE_BACK_REQ);
|
||||
memcpy(bar->ra, ra, ETH_ALEN);
|
||||
|
||||
@@ -330,8 +330,7 @@ static ssize_t ieee80211_if_parse_tkip_mic_test(
|
||||
return -ENOMEM;
|
||||
skb_reserve(skb, local->hw.extra_tx_headroom);
|
||||
|
||||
hdr = (struct ieee80211_hdr *) skb_put(skb, 24);
|
||||
memset(hdr, 0, 24);
|
||||
hdr = skb_put_zero(skb, 24);
|
||||
fc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_DATA);
|
||||
|
||||
switch (sdata->vif.type) {
|
||||
@@ -367,7 +366,7 @@ static ssize_t ieee80211_if_parse_tkip_mic_test(
|
||||
* The exact contents does not matter since the recipient is required
|
||||
* to drop this because of the Michael MIC failure.
|
||||
*/
|
||||
memset(skb_put(skb, 50), 0, 50);
|
||||
skb_put_zero(skb, 50);
|
||||
|
||||
IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_TKIP_MIC_FAILURE;
|
||||
|
||||
|
||||
@@ -394,8 +394,7 @@ void ieee80211_send_delba(struct ieee80211_sub_if_data *sdata,
|
||||
return;
|
||||
|
||||
skb_reserve(skb, local->hw.extra_tx_headroom);
|
||||
mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24);
|
||||
memset(mgmt, 0, 24);
|
||||
mgmt = skb_put_zero(skb, 24);
|
||||
memcpy(mgmt->da, da, ETH_ALEN);
|
||||
memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
|
||||
if (sdata->vif.type == NL80211_IFTYPE_AP ||
|
||||
|
||||
@@ -719,8 +719,7 @@ ieee80211_mesh_build_beacon(struct ieee80211_if_mesh *ifmsh)
|
||||
bcn->head = ((u8 *) bcn) + sizeof(*bcn);
|
||||
|
||||
/* fill in the head */
|
||||
mgmt = (struct ieee80211_mgmt *) skb_put(skb, hdr_len);
|
||||
memset(mgmt, 0, hdr_len);
|
||||
mgmt = skb_put_zero(skb, hdr_len);
|
||||
mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
|
||||
IEEE80211_STYPE_BEACON);
|
||||
eth_broadcast_addr(mgmt->da);
|
||||
|
||||
@@ -120,8 +120,7 @@ static int mesh_path_sel_frame_tx(enum mpath_frame_type action, u8 flags,
|
||||
if (!skb)
|
||||
return -1;
|
||||
skb_reserve(skb, local->tx_headroom);
|
||||
mgmt = (struct ieee80211_mgmt *) skb_put(skb, hdr_len);
|
||||
memset(mgmt, 0, hdr_len);
|
||||
mgmt = skb_put_zero(skb, hdr_len);
|
||||
mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
|
||||
IEEE80211_STYPE_ACTION);
|
||||
|
||||
@@ -257,8 +256,7 @@ int mesh_path_error_tx(struct ieee80211_sub_if_data *sdata,
|
||||
if (!skb)
|
||||
return -1;
|
||||
skb_reserve(skb, local->tx_headroom + sdata->encrypt_headroom);
|
||||
mgmt = (struct ieee80211_mgmt *) skb_put(skb, hdr_len);
|
||||
memset(mgmt, 0, hdr_len);
|
||||
mgmt = skb_put_zero(skb, hdr_len);
|
||||
mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
|
||||
IEEE80211_STYPE_ACTION);
|
||||
|
||||
|
||||
@@ -242,8 +242,7 @@ static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata,
|
||||
return err;
|
||||
info = IEEE80211_SKB_CB(skb);
|
||||
skb_reserve(skb, local->tx_headroom);
|
||||
mgmt = (struct ieee80211_mgmt *) skb_put(skb, hdr_len);
|
||||
memset(mgmt, 0, hdr_len);
|
||||
mgmt = skb_put_zero(skb, hdr_len);
|
||||
mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
|
||||
IEEE80211_STYPE_ACTION);
|
||||
memcpy(mgmt->da, da, ETH_ALEN);
|
||||
|
||||
@@ -39,7 +39,7 @@ static struct sk_buff *mps_qos_null_get(struct sta_info *sta)
|
||||
nullfunc->seq_ctrl = 0;
|
||||
/* no address resolution for this frame -> set addr 1 immediately */
|
||||
memcpy(nullfunc->addr1, sta->sta.addr, ETH_ALEN);
|
||||
memset(skb_put(skb, 2), 0, 2); /* append QoS control field */
|
||||
skb_put_zero(skb, 2); /* append QoS control field */
|
||||
ieee80211_mps_set_frame_flags(sdata, sta, nullfunc);
|
||||
|
||||
return skb;
|
||||
|
||||
@@ -674,8 +674,7 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata)
|
||||
if (ifmgd->flags & IEEE80211_STA_ENABLE_RRM)
|
||||
capab |= WLAN_CAPABILITY_RADIO_MEASURE;
|
||||
|
||||
mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24);
|
||||
memset(mgmt, 0, 24);
|
||||
mgmt = skb_put_zero(skb, 24);
|
||||
memcpy(mgmt->da, assoc_data->bss->bssid, ETH_ALEN);
|
||||
memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
|
||||
memcpy(mgmt->bssid, assoc_data->bss->bssid, ETH_ALEN);
|
||||
@@ -949,8 +948,7 @@ static void ieee80211_send_4addr_nullfunc(struct ieee80211_local *local,
|
||||
|
||||
skb_reserve(skb, local->hw.extra_tx_headroom);
|
||||
|
||||
nullfunc = (struct ieee80211_hdr *) skb_put(skb, 30);
|
||||
memset(nullfunc, 0, 30);
|
||||
nullfunc = skb_put_zero(skb, 30);
|
||||
fc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC |
|
||||
IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS);
|
||||
nullfunc->frame_control = fc;
|
||||
|
||||
@@ -2760,8 +2760,7 @@ static void ieee80211_process_sa_query_req(struct ieee80211_sub_if_data *sdata,
|
||||
return;
|
||||
|
||||
skb_reserve(skb, local->hw.extra_tx_headroom);
|
||||
resp = (struct ieee80211_mgmt *) skb_put(skb, 24);
|
||||
memset(resp, 0, 24);
|
||||
resp = skb_put_zero(skb, 24);
|
||||
memcpy(resp->da, mgmt->sa, ETH_ALEN);
|
||||
memcpy(resp->sa, sdata->vif.addr, ETH_ALEN);
|
||||
memcpy(resp->bssid, sdata->u.mgd.bssid, ETH_ALEN);
|
||||
|
||||
@@ -193,8 +193,7 @@ static void ieee80211_send_refuse_measurement_request(struct ieee80211_sub_if_da
|
||||
return;
|
||||
|
||||
skb_reserve(skb, local->hw.extra_tx_headroom);
|
||||
msr_report = (struct ieee80211_mgmt *)skb_put(skb, 24);
|
||||
memset(msr_report, 0, 24);
|
||||
msr_report = skb_put_zero(skb, 24);
|
||||
memcpy(msr_report->da, da, ETH_ALEN);
|
||||
memcpy(msr_report->sa, sdata->vif.addr, ETH_ALEN);
|
||||
memcpy(msr_report->bssid, bssid, ETH_ALEN);
|
||||
|
||||
@@ -271,8 +271,7 @@ static void ieee80211_tdls_add_wmm_param_ie(struct ieee80211_sub_if_data *sdata,
|
||||
struct ieee80211_tx_queue_params *txq;
|
||||
int i;
|
||||
|
||||
wmm = (void *)skb_put(skb, sizeof(*wmm));
|
||||
memset(wmm, 0, sizeof(*wmm));
|
||||
wmm = skb_put_zero(skb, sizeof(*wmm));
|
||||
|
||||
wmm->element_id = WLAN_EID_VENDOR_SPECIFIC;
|
||||
wmm->len = sizeof(*wmm) - 2;
|
||||
@@ -838,8 +837,7 @@ ieee80211_prep_tdls_direct(struct wiphy *wiphy, struct net_device *dev,
|
||||
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
|
||||
struct ieee80211_mgmt *mgmt;
|
||||
|
||||
mgmt = (void *)skb_put(skb, 24);
|
||||
memset(mgmt, 0, 24);
|
||||
mgmt = skb_put_zero(skb, 24);
|
||||
memcpy(mgmt->da, peer, ETH_ALEN);
|
||||
memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
|
||||
memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
|
||||
|
||||
@@ -3044,7 +3044,7 @@ static bool ieee80211_amsdu_realloc_pad(struct ieee80211_local *local,
|
||||
|
||||
if (padding) {
|
||||
*subframe_len += padding;
|
||||
memset(skb_put(skb, padding), 0, padding);
|
||||
skb_put_zero(skb, padding);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -4370,8 +4370,7 @@ struct sk_buff *ieee80211_pspoll_get(struct ieee80211_hw *hw,
|
||||
|
||||
skb_reserve(skb, local->hw.extra_tx_headroom);
|
||||
|
||||
pspoll = (struct ieee80211_pspoll *) skb_put(skb, sizeof(*pspoll));
|
||||
memset(pspoll, 0, sizeof(*pspoll));
|
||||
pspoll = skb_put_zero(skb, sizeof(*pspoll));
|
||||
pspoll->frame_control = cpu_to_le16(IEEE80211_FTYPE_CTL |
|
||||
IEEE80211_STYPE_PSPOLL);
|
||||
pspoll->aid = cpu_to_le16(ifmgd->aid);
|
||||
@@ -4408,9 +4407,7 @@ struct sk_buff *ieee80211_nullfunc_get(struct ieee80211_hw *hw,
|
||||
|
||||
skb_reserve(skb, local->hw.extra_tx_headroom);
|
||||
|
||||
nullfunc = (struct ieee80211_hdr_3addr *) skb_put(skb,
|
||||
sizeof(*nullfunc));
|
||||
memset(nullfunc, 0, sizeof(*nullfunc));
|
||||
nullfunc = skb_put_zero(skb, sizeof(*nullfunc));
|
||||
nullfunc->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA |
|
||||
IEEE80211_STYPE_NULLFUNC |
|
||||
IEEE80211_FCTL_TODS);
|
||||
@@ -4442,8 +4439,7 @@ struct sk_buff *ieee80211_probereq_get(struct ieee80211_hw *hw,
|
||||
|
||||
skb_reserve(skb, local->hw.extra_tx_headroom);
|
||||
|
||||
hdr = (struct ieee80211_hdr_3addr *) skb_put(skb, sizeof(*hdr));
|
||||
memset(hdr, 0, sizeof(*hdr));
|
||||
hdr = skb_put_zero(skb, sizeof(*hdr));
|
||||
hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
|
||||
IEEE80211_STYPE_PROBE_REQ);
|
||||
eth_broadcast_addr(hdr->addr1);
|
||||
|
||||
@@ -1242,8 +1242,7 @@ void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
|
||||
|
||||
skb_reserve(skb, local->hw.extra_tx_headroom + IEEE80211_WEP_IV_LEN);
|
||||
|
||||
mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24 + 6);
|
||||
memset(mgmt, 0, 24 + 6);
|
||||
mgmt = skb_put_zero(skb, 24 + 6);
|
||||
mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
|
||||
IEEE80211_STYPE_AUTH);
|
||||
memcpy(mgmt->da, da, ETH_ALEN);
|
||||
@@ -2999,8 +2998,7 @@ int ieee80211_send_action_csa(struct ieee80211_sub_if_data *sdata,
|
||||
return -ENOMEM;
|
||||
|
||||
skb_reserve(skb, local->tx_headroom);
|
||||
mgmt = (struct ieee80211_mgmt *)skb_put(skb, hdr_len);
|
||||
memset(mgmt, 0, hdr_len);
|
||||
mgmt = skb_put_zero(skb, hdr_len);
|
||||
mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
|
||||
IEEE80211_STYPE_ACTION);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user