networking: make skb_put & friends return void pointers
It seems like a historic accident that these return unsigned char *, and in many places that means casts are required, more often than not. Make these functions (skb_put, __skb_put and pskb_put) return void * and remove all the casts across the tree, adding a (u8 *) cast only where the unsigned char pointer was used directly, all done with the following spatch: @@ expression SKB, LEN; typedef u8; identifier fn = { skb_put, __skb_put }; @@ - *(fn(SKB, LEN)) + *(u8 *)fn(SKB, LEN) @@ expression E, SKB, LEN; identifier fn = { skb_put, __skb_put }; type T; @@ - E = ((T *)(fn(SKB, LEN))) + E = fn(SKB, LEN) which actually doesn't cover pskb_put since there are only three users overall. A handful of stragglers were converted manually, notably a macro in drivers/isdn/i4l/isdn_bsdcomp.c and, oddly enough, one of the many instances in net/bluetooth/hci_sock.c. In the former file, I also had to fix one whitespace problem spatch introduced. 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
59ae1d127a
commit
4df864c1d9
@@ -348,7 +348,7 @@ void ath6kl_debug_fwlog_event(struct ath6kl *ar, const void *buf, size_t len)
|
||||
if (!skb)
|
||||
return;
|
||||
|
||||
slot = (struct ath6kl_fwlog_slot *) skb_put(skb, slot_len);
|
||||
slot = skb_put(skb, slot_len);
|
||||
slot->timestamp = cpu_to_le32(jiffies);
|
||||
slot->length = cpu_to_le32(len);
|
||||
memcpy(slot->payload, buf, len);
|
||||
|
@@ -1274,8 +1274,7 @@ static int ath6kl_htc_pipe_conn_service(struct htc_target *target,
|
||||
length = sizeof(struct htc_conn_service_msg);
|
||||
|
||||
/* assemble connect service message */
|
||||
conn_msg = (struct htc_conn_service_msg *) skb_put(skb,
|
||||
length);
|
||||
conn_msg = skb_put(skb, length);
|
||||
if (conn_msg == NULL) {
|
||||
WARN_ON_ONCE(1);
|
||||
status = -EINVAL;
|
||||
@@ -1504,8 +1503,7 @@ static int ath6kl_htc_pipe_start(struct htc_target *target)
|
||||
skb = packet->skb;
|
||||
|
||||
/* assemble setup complete message */
|
||||
setup = (struct htc_setup_comp_ext_msg *) skb_put(skb,
|
||||
sizeof(*setup));
|
||||
setup = skb_put(skb, sizeof(*setup));
|
||||
memset(setup, 0, sizeof(struct htc_setup_comp_ext_msg));
|
||||
setup->msg_id = cpu_to_le16(HTC_MSG_SETUP_COMPLETE_EX_ID);
|
||||
|
||||
|
@@ -156,8 +156,7 @@ static int htc_config_pipe_credits(struct htc_target *target)
|
||||
}
|
||||
skb_reserve(skb, sizeof(struct htc_frame_hdr));
|
||||
|
||||
cp_msg = (struct htc_config_pipe_msg *)
|
||||
skb_put(skb, sizeof(struct htc_config_pipe_msg));
|
||||
cp_msg = skb_put(skb, sizeof(struct htc_config_pipe_msg));
|
||||
|
||||
cp_msg->message_id = cpu_to_be16(HTC_MSG_CONFIG_PIPE_ID);
|
||||
cp_msg->pipe_id = USB_WLAN_TX_PIPE;
|
||||
@@ -195,8 +194,7 @@ static int htc_setup_complete(struct htc_target *target)
|
||||
}
|
||||
skb_reserve(skb, sizeof(struct htc_frame_hdr));
|
||||
|
||||
comp_msg = (struct htc_comp_msg *)
|
||||
skb_put(skb, sizeof(struct htc_comp_msg));
|
||||
comp_msg = skb_put(skb, sizeof(struct htc_comp_msg));
|
||||
comp_msg->msg_id = cpu_to_be16(HTC_MSG_SETUP_COMPLETE_ID);
|
||||
|
||||
target->htc_flags |= HTC_OP_START_WAIT;
|
||||
@@ -265,8 +263,7 @@ int htc_connect_service(struct htc_target *target,
|
||||
|
||||
skb_reserve(skb, sizeof(struct htc_frame_hdr));
|
||||
|
||||
conn_msg = (struct htc_conn_svc_msg *)
|
||||
skb_put(skb, sizeof(struct htc_conn_svc_msg));
|
||||
conn_msg = skb_put(skb, sizeof(struct htc_conn_svc_msg));
|
||||
conn_msg->service_id = cpu_to_be16(service_connreq->service_id);
|
||||
conn_msg->msg_id = cpu_to_be16(HTC_MSG_CONNECT_SERVICE_ID);
|
||||
conn_msg->con_flags = cpu_to_be16(service_connreq->con_flags);
|
||||
|
@@ -677,7 +677,7 @@ static void wmi_evt_eapol_rx(struct wil6210_priv *wil, int id,
|
||||
return;
|
||||
}
|
||||
|
||||
eth = (struct ethhdr *)skb_put(skb, ETH_HLEN);
|
||||
eth = skb_put(skb, ETH_HLEN);
|
||||
ether_addr_copy(eth->h_dest, ndev->dev_addr);
|
||||
ether_addr_copy(eth->h_source, evt->src_mac);
|
||||
eth->h_proto = cpu_to_be16(ETH_P_PAE);
|
||||
|
Reference in New Issue
Block a user