You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
networking: make skb_push & __skb_push 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 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_push, __skb_push, skb_push_rcsum };
@@
- *(fn(SKB, LEN))
+ *(u8 *)fn(SKB, LEN)
@@
expression E, SKB, LEN;
identifier fn = { skb_push, __skb_push, skb_push_rcsum };
type T;
@@
- E = ((T *)(fn(SKB, LEN)))
+ E = fn(SKB, LEN)
@@
expression SKB, LEN;
identifier fn = { skb_push, __skb_push, skb_push_rcsum };
@@
- fn(SKB, LEN)[0]
+ *(u8 *)fn(SKB, LEN)
Note that the last part there converts from push(...)[0] to the
more idiomatic *(u8 *)push(...).
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
af72868b90
commit
d58ff35122
@@ -1174,7 +1174,7 @@ static int psend(struct atm_vcc *vcc, struct sk_buff *skb)
|
||||
}
|
||||
}
|
||||
|
||||
header = (void *)skb_push(skb, sizeof(*header));
|
||||
header = skb_push(skb, sizeof(*header));
|
||||
|
||||
/* This does _not_ include the size of the header */
|
||||
header->size = cpu_to_le16(pktlen);
|
||||
|
||||
@@ -297,7 +297,7 @@ static int bpa10x_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
|
||||
return -ENOMEM;
|
||||
|
||||
/* Prepend skb with frame type */
|
||||
*skb_push(skb, 1) = hci_skb_pkt_type(skb);
|
||||
*(u8 *)skb_push(skb, 1) = hci_skb_pkt_type(skb);
|
||||
|
||||
switch (hci_skb_pkt_type(skb)) {
|
||||
case HCI_COMMAND_PKT:
|
||||
|
||||
@@ -219,7 +219,7 @@ static int fwnet_header_create(struct sk_buff *skb, struct net_device *net,
|
||||
{
|
||||
struct fwnet_header *h;
|
||||
|
||||
h = (struct fwnet_header *)skb_push(skb, sizeof(*h));
|
||||
h = skb_push(skb, sizeof(*h));
|
||||
put_unaligned_be16(type, &h->h_proto);
|
||||
|
||||
if (net->flags & (IFF_LOOPBACK | IFF_NOARP)) {
|
||||
@@ -961,16 +961,14 @@ static int fwnet_send_packet(struct fwnet_packet_task *ptask)
|
||||
tx_len = ptask->max_payload;
|
||||
switch (fwnet_get_hdr_lf(&ptask->hdr)) {
|
||||
case RFC2374_HDR_UNFRAG:
|
||||
bufhdr = (struct rfc2734_header *)
|
||||
skb_push(ptask->skb, RFC2374_UNFRAG_HDR_SIZE);
|
||||
bufhdr = skb_push(ptask->skb, RFC2374_UNFRAG_HDR_SIZE);
|
||||
put_unaligned_be32(ptask->hdr.w0, &bufhdr->w0);
|
||||
break;
|
||||
|
||||
case RFC2374_HDR_FIRSTFRAG:
|
||||
case RFC2374_HDR_INTFRAG:
|
||||
case RFC2374_HDR_LASTFRAG:
|
||||
bufhdr = (struct rfc2734_header *)
|
||||
skb_push(ptask->skb, RFC2374_FRAG_HDR_SIZE);
|
||||
bufhdr = skb_push(ptask->skb, RFC2374_FRAG_HDR_SIZE);
|
||||
put_unaligned_be32(ptask->hdr.w0, &bufhdr->w0);
|
||||
put_unaligned_be32(ptask->hdr.w1, &bufhdr->w1);
|
||||
break;
|
||||
|
||||
@@ -513,7 +513,7 @@ static void send_mpa_req(struct iwch_ep *ep, struct sk_buff *skb)
|
||||
set_arp_failure_handler(skb, arp_failure_discard);
|
||||
skb_reset_transport_header(skb);
|
||||
len = skb->len;
|
||||
req = (struct tx_data_wr *) skb_push(skb, sizeof(*req));
|
||||
req = skb_push(skb, sizeof(*req));
|
||||
req->wr_hi = htonl(V_WR_OP(FW_WROPCODE_OFLD_TX_DATA)|F_WR_COMPL);
|
||||
req->wr_lo = htonl(V_WR_TID(ep->hwtid));
|
||||
req->len = htonl(len);
|
||||
@@ -564,7 +564,7 @@ static int send_mpa_reject(struct iwch_ep *ep, const void *pdata, u8 plen)
|
||||
skb->priority = CPL_PRIORITY_DATA;
|
||||
set_arp_failure_handler(skb, arp_failure_discard);
|
||||
skb_reset_transport_header(skb);
|
||||
req = (struct tx_data_wr *) skb_push(skb, sizeof(*req));
|
||||
req = skb_push(skb, sizeof(*req));
|
||||
req->wr_hi = htonl(V_WR_OP(FW_WROPCODE_OFLD_TX_DATA)|F_WR_COMPL);
|
||||
req->wr_lo = htonl(V_WR_TID(ep->hwtid));
|
||||
req->len = htonl(mpalen);
|
||||
@@ -615,7 +615,7 @@ static int send_mpa_reply(struct iwch_ep *ep, const void *pdata, u8 plen)
|
||||
set_arp_failure_handler(skb, arp_failure_discard);
|
||||
skb_reset_transport_header(skb);
|
||||
len = skb->len;
|
||||
req = (struct tx_data_wr *) skb_push(skb, sizeof(*req));
|
||||
req = skb_push(skb, sizeof(*req));
|
||||
req->wr_hi = htonl(V_WR_OP(FW_WROPCODE_OFLD_TX_DATA)|F_WR_COMPL);
|
||||
req->wr_lo = htonl(V_WR_TID(ep->hwtid));
|
||||
req->len = htonl(len);
|
||||
|
||||
@@ -3751,7 +3751,7 @@ static void build_cpl_pass_accept_req(struct sk_buff *skb, int stid , u8 tos)
|
||||
tcp_clear_options(&tmp_opt);
|
||||
tcp_parse_options(&init_net, skb, &tmp_opt, 0, NULL);
|
||||
|
||||
req = (struct cpl_pass_accept_req *)__skb_push(skb, sizeof(*req));
|
||||
req = __skb_push(skb, sizeof(*req));
|
||||
memset(req, 0, sizeof(*req));
|
||||
req->l2info = cpu_to_be16(SYN_INTF_V(intf) |
|
||||
SYN_MAC_IDX_V(RX_MACIDX_G(
|
||||
|
||||
@@ -681,7 +681,7 @@ static void push_pseudo_header(struct sk_buff *skb, const char *daddr)
|
||||
{
|
||||
struct ipoib_pseudo_header *phdr;
|
||||
|
||||
phdr = (struct ipoib_pseudo_header *)skb_push(skb, sizeof(*phdr));
|
||||
phdr = skb_push(skb, sizeof(*phdr));
|
||||
memcpy(phdr->hwaddr, daddr, INFINIBAND_ALEN);
|
||||
}
|
||||
|
||||
@@ -1129,7 +1129,7 @@ static int ipoib_hard_header(struct sk_buff *skb,
|
||||
{
|
||||
struct ipoib_header *header;
|
||||
|
||||
header = (struct ipoib_header *) skb_push(skb, sizeof *header);
|
||||
header = skb_push(skb, sizeof *header);
|
||||
|
||||
header->proto = htons(type);
|
||||
header->reserved = 0;
|
||||
|
||||
@@ -460,7 +460,7 @@ void opa_vnic_encap_skb(struct opa_vnic_adapter *adapter, struct sk_buff *skb)
|
||||
sc = opa_vnic_get_sc(info, skb);
|
||||
l4_hdr = info->vesw.vesw_id;
|
||||
|
||||
mdata = (struct opa_vnic_skb_mdata *)skb_push(skb, sizeof(*mdata));
|
||||
mdata = skb_push(skb, sizeof(*mdata));
|
||||
mdata->vl = opa_vnic_get_vl(adapter, skb);
|
||||
mdata->entropy = entropy;
|
||||
mdata->flags = 0;
|
||||
|
||||
@@ -103,7 +103,7 @@ static u16 opa_vnic_select_queue(struct net_device *netdev, struct sk_buff *skb,
|
||||
int rc;
|
||||
|
||||
/* pass entropy and vl as metadata in skb */
|
||||
mdata = (struct opa_vnic_skb_mdata *)skb_push(skb, sizeof(*mdata));
|
||||
mdata = skb_push(skb, sizeof(*mdata));
|
||||
mdata->entropy = opa_vnic_calc_entropy(adapter, skb);
|
||||
mdata->vl = opa_vnic_get_vl(adapter, skb);
|
||||
rc = adapter->rn_ops->ndo_select_queue(netdev, skb,
|
||||
|
||||
@@ -1312,7 +1312,7 @@ isdn_ppp_xmit(struct sk_buff *skb, struct net_device *netdev)
|
||||
/* check if we should pass this packet
|
||||
* the filter instructions are constructed assuming
|
||||
* a four-byte PPP header on each packet */
|
||||
*skb_push(skb, 4) = 1; /* indicate outbound */
|
||||
*(u8 *)skb_push(skb, 4) = 1; /* indicate outbound */
|
||||
|
||||
{
|
||||
__be16 *p = (__be16 *)skb->data;
|
||||
|
||||
@@ -85,7 +85,7 @@ static int build_header(struct sk_buff *skb, struct net_device *dev,
|
||||
unsigned short type, uint8_t daddr)
|
||||
{
|
||||
int hdr_size = ARC_HDR_SIZE;
|
||||
struct archdr *pkt = (struct archdr *)skb_push(skb, hdr_size);
|
||||
struct archdr *pkt = skb_push(skb, hdr_size);
|
||||
|
||||
/* Set the source hardware address.
|
||||
*
|
||||
|
||||
@@ -101,7 +101,7 @@ static int build_header(struct sk_buff *skb,
|
||||
uint8_t daddr)
|
||||
{
|
||||
int hdr_size = ARC_HDR_SIZE;
|
||||
struct archdr *pkt = (struct archdr *)skb_push(skb, hdr_size);
|
||||
struct archdr *pkt = skb_push(skb, hdr_size);
|
||||
|
||||
arc_printk(D_PROTO, dev, "Preparing header for cap packet %x.\n",
|
||||
*((int *)&pkt->soft.cap.cookie[0]));
|
||||
|
||||
@@ -162,7 +162,7 @@ static int build_header(struct sk_buff *skb, struct net_device *dev,
|
||||
unsigned short type, uint8_t daddr)
|
||||
{
|
||||
int hdr_size = ARC_HDR_SIZE + RFC1051_HDR_SIZE;
|
||||
struct archdr *pkt = (struct archdr *)skb_push(skb, hdr_size);
|
||||
struct archdr *pkt = skb_push(skb, hdr_size);
|
||||
struct arc_rfc1051 *soft = &pkt->soft.rfc1051;
|
||||
|
||||
/* set the protocol ID according to RFC1051 */
|
||||
|
||||
@@ -379,7 +379,7 @@ static int build_header(struct sk_buff *skb, struct net_device *dev,
|
||||
{
|
||||
struct arcnet_local *lp = netdev_priv(dev);
|
||||
int hdr_size = ARC_HDR_SIZE + RFC1201_HDR_SIZE;
|
||||
struct archdr *pkt = (struct archdr *)skb_push(skb, hdr_size);
|
||||
struct archdr *pkt = skb_push(skb, hdr_size);
|
||||
struct arc_rfc1201 *soft = &pkt->soft.rfc1201;
|
||||
|
||||
/* set the protocol ID according to RFC1201 */
|
||||
|
||||
@@ -1099,7 +1099,7 @@ static struct sk_buff *bcm_sysport_insert_tsb(struct sk_buff *skb,
|
||||
skb = nskb;
|
||||
}
|
||||
|
||||
tsb = (struct bcm_tsb *)skb_push(skb, sizeof(*tsb));
|
||||
tsb = skb_push(skb, sizeof(*tsb));
|
||||
/* Zero-out TSB by default */
|
||||
memset(tsb, 0, sizeof(*tsb));
|
||||
|
||||
|
||||
@@ -1801,7 +1801,7 @@ netdev_tx_t t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
|
||||
eth_type = skb_network_offset(skb) == ETH_HLEN ?
|
||||
CPL_ETH_II : CPL_ETH_II_VLAN;
|
||||
|
||||
hdr = (struct cpl_tx_pkt_lso *)skb_push(skb, sizeof(*hdr));
|
||||
hdr = skb_push(skb, sizeof(*hdr));
|
||||
hdr->opcode = CPL_TX_PKT_LSO;
|
||||
hdr->ip_csum_dis = hdr->l4_csum_dis = 0;
|
||||
hdr->ip_hdr_words = ip_hdr(skb)->ihl;
|
||||
@@ -1849,7 +1849,7 @@ netdev_tx_t t1_start_xmit(struct sk_buff *skb, struct net_device *dev)
|
||||
}
|
||||
}
|
||||
|
||||
cpl = (struct cpl_tx_pkt *)__skb_push(skb, sizeof(*cpl));
|
||||
cpl = __skb_push(skb, sizeof(*cpl));
|
||||
cpl->opcode = CPL_TX_PKT;
|
||||
cpl->ip_csum_dis = 1; /* SW calculates IP csum */
|
||||
cpl->l4_csum_dis = skb->ip_summed == CHECKSUM_PARTIAL ? 0 : 1;
|
||||
|
||||
@@ -2250,7 +2250,7 @@ static int gfar_enet_open(struct net_device *dev)
|
||||
|
||||
static inline struct txfcb *gfar_add_fcb(struct sk_buff *skb)
|
||||
{
|
||||
struct txfcb *fcb = (struct txfcb *)skb_push(skb, GMAC_FCB_LEN);
|
||||
struct txfcb *fcb = skb_push(skb, GMAC_FCB_LEN);
|
||||
|
||||
memset(fcb, 0, GMAC_FCB_LEN);
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ static struct sk_buff *mlx5e_test_get_udp_skb(struct mlx5e_priv *priv)
|
||||
skb_reserve(skb, NET_IP_ALIGN);
|
||||
|
||||
/* Reserve for ethernet and IP header */
|
||||
ethh = (struct ethhdr *)skb_push(skb, ETH_HLEN);
|
||||
ethh = skb_push(skb, ETH_HLEN);
|
||||
skb_reset_mac_header(skb);
|
||||
|
||||
skb_set_network_header(skb, skb->len);
|
||||
|
||||
@@ -6667,7 +6667,7 @@ static netdev_tx_t niu_start_xmit(struct sk_buff *skb,
|
||||
headroom = align + sizeof(struct tx_pkt_hdr);
|
||||
|
||||
ehdr = (struct ethhdr *) skb->data;
|
||||
tp = (struct tx_pkt_hdr *) skb_push(skb, headroom);
|
||||
tp = skb_push(skb, headroom);
|
||||
|
||||
len = skb->len - sizeof(struct tx_pkt_hdr);
|
||||
tp->flags = cpu_to_le64(niu_compute_tx_flags(skb, ehdr, align, len));
|
||||
|
||||
@@ -754,7 +754,7 @@ static struct sk_buff *gelic_put_vlan_tag(struct sk_buff *skb,
|
||||
return NULL;
|
||||
dev_kfree_skb_any(sk_tmp);
|
||||
}
|
||||
veth = (struct vlan_ethhdr *)skb_push(skb, VLAN_HLEN);
|
||||
veth = skb_push(skb, VLAN_HLEN);
|
||||
|
||||
/* Move the mac addresses to the top of buffer */
|
||||
memmove(skb->data, skb->data + VLAN_HLEN, 2 * ETH_ALEN);
|
||||
|
||||
@@ -687,8 +687,7 @@ static int geneve_build_skb(struct dst_entry *dst, struct sk_buff *skb,
|
||||
if (err)
|
||||
goto free_dst;
|
||||
|
||||
gnvh = (struct genevehdr *)__skb_push(skb, sizeof(*gnvh) +
|
||||
info->options_len);
|
||||
gnvh = __skb_push(skb, sizeof(*gnvh) + info->options_len);
|
||||
geneve_build_header(gnvh, info);
|
||||
skb_set_inner_protocol(skb, htons(ETH_P_TEB));
|
||||
return 0;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user