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 <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
This commit is contained in:
Johannes Berg 2017-06-16 14:29:23 +02:00 • committed by David S. Miller
commit d58ff35122
126 changed files with 204 additions and 234 deletions

View file

@ -79,8 +79,8 @@ static void fdp_nci_i2c_add_len_lrc(struct sk_buff *skb)
/* Add length header */
len = skb->len;
*skb_push(skb, 1) = len & 0xff;
*skb_push(skb, 1) = len >> 8;
*(u8 *)skb_push(skb, 1) = len & 0xff;
*(u8 *)skb_push(skb, 1) = len >> 8;
/* Compute and add lrc */
for (i = 0; i < len + 2; i++)

View file

@ -70,7 +70,7 @@ static void microread_i2c_add_len_crc(struct sk_buff *skb)
int len;
len = skb->len;
*skb_push(skb, 1) = len;
*(u8 *)skb_push(skb, 1) = len;
for (i = 0; i < skb->len; i++)
crc = crc ^ skb->data[i];

View file

@ -419,7 +419,7 @@ static int microread_im_transceive(struct nfc_hci_dev *hdev,
pr_info("data exchange to gate 0x%x\n", target->hci_reader_gate);
if (target->hci_reader_gate == MICROREAD_GATE_ID_P2P_INITIATOR) {
*skb_push(skb, 1) = 0;
*(u8 *)skb_push(skb, 1) = 0;
return nfc_hci_send_event(hdev, target->hci_reader_gate,
MICROREAD_EVT_P2P_INITIATOR_EXCHANGE_TO_RF,
@ -453,7 +453,7 @@ static int microread_im_transceive(struct nfc_hci_dev *hdev,
return 1;
}
*skb_push(skb, 1) = control_bits;
*(u8 *)skb_push(skb, 1) = control_bits;
info->async_cb_type = MICROREAD_CB_TYPE_READER_ALL;
info->async_cb = cb;

View file

@ -68,7 +68,7 @@ static int nfcmrvl_nci_send(struct nci_dev *ndev, struct sk_buff *skb)
unsigned char *hdr;
unsigned char len = skb->len;
hdr = (char *) skb_push(skb, NFCMRVL_HCI_EVENT_HEADER_SIZE);
hdr = skb_push(skb, NFCMRVL_HCI_EVENT_HEADER_SIZE);
hdr[0] = NFCMRVL_HCI_COMMAND_CODE;
hdr[1] = NFCMRVL_HCI_OGF;
hdr[2] = NFCMRVL_HCI_OCF;

View file

@ -2090,10 +2090,10 @@ static int pn533_fill_fragment_skbs(struct pn533 *dev, struct sk_buff *skb)
/* MI + TG */
if (frag_size == PN533_CMD_DATAFRAME_MAXLEN)
*skb_push(frag, sizeof(u8)) =
(PN533_CMD_MI_MASK | 1);
*(u8 *)skb_push(frag, sizeof(u8)) =
(PN533_CMD_MI_MASK | 1);
else
*skb_push(frag, sizeof(u8)) = 1; /* TG */
*(u8 *)skb_push(frag, sizeof(u8)) = 1; /* TG */
}
skb_put_data(frag, skb->data, frag_size);
@ -2160,7 +2160,7 @@ static int pn533_transceive(struct nfc_dev *nfc_dev,
goto error;
}
} else {
*skb_push(skb, sizeof(u8)) = 1; /* TG */
*(u8 *)skb_push(skb, sizeof(u8)) = 1; /* TG */
}
rc = pn533_send_data_async(dev, PN533_CMD_IN_DATA_EXCHANGE,

View file

@ -283,7 +283,7 @@ static void pn544_hci_i2c_add_len_crc(struct sk_buff *skb)
int len;
len = skb->len + 2;
*skb_push(skb, 1) = len;
*(u8 *)skb_push(skb, 1) = len;
crc = crc_ccitt(0xffff, skb->data, skb->len);
crc = ~crc;

View file

@ -649,8 +649,8 @@ static int pn544_hci_im_transceive(struct nfc_hci_dev *hdev,
} else
return 1;
case PN544_RF_READER_F_GATE:
*skb_push(skb, 1) = 0;
*skb_push(skb, 1) = 0;
*(u8 *)skb_push(skb, 1) = 0;
*(u8 *)skb_push(skb, 1) = 0;
info->async_cb_type = PN544_CB_TYPE_READER_F;
info->async_cb = cb;
@ -665,7 +665,7 @@ static int pn544_hci_im_transceive(struct nfc_hci_dev *hdev,
PN544_JEWEL_RAW_CMD, skb->data,
skb->len, cb, cb_context);
case PN544_RF_READER_NFCIP1_INITIATOR_GATE:
*skb_push(skb, 1) = 0;
*(u8 *)skb_push(skb, 1) = 0;
return nfc_hci_send_event(hdev, target->hci_reader_gate,
PN544_HCI_EVT_SND_DATA, skb->data,
@ -680,7 +680,7 @@ static int pn544_hci_tm_send(struct nfc_hci_dev *hdev, struct sk_buff *skb)
int r;
/* Set default false for multiple information chaining */
*skb_push(skb, 1) = 0;
*(u8 *)skb_push(skb, 1) = 0;
r = nfc_hci_send_event(hdev, PN544_RF_READER_NFCIP1_TARGET_GATE,
PN544_HCI_EVT_SND_DATA, skb->data, skb->len);

View file

@ -87,7 +87,7 @@ int ndlc_send(struct llt_ndlc *ndlc, struct sk_buff *skb)
u8 pcb = PCB_TYPE_DATAFRAME | PCB_DATAFRAME_RETRANSMIT_NO |
PCB_FRAME_CRC_INFO_NOTPRESENT;
*skb_push(skb, 1) = pcb;
*(u8 *)skb_push(skb, 1) = pcb;
skb_queue_tail(&ndlc->send_q, skb);
schedule_work(&ndlc->sm_work);

View file

@ -782,12 +782,12 @@ static int st21nfca_hci_im_transceive(struct nfc_hci_dev *hdev,
if (target->supported_protocols == NFC_PROTO_NFC_DEP_MASK)
return st21nfca_im_send_dep_req(hdev, skb);
*skb_push(skb, 1) = 0x1a;
*(u8 *)skb_push(skb, 1) = 0x1a;
return nfc_hci_send_cmd_async(hdev, target->hci_reader_gate,
ST21NFCA_WR_XCHG_DATA, skb->data,
skb->len, cb, cb_context);
case ST21NFCA_RF_READER_14443_3_A_GATE:
*skb_push(skb, 1) = 0x1a; /* CTR, see spec:10.2.2.1 */
*(u8 *)skb_push(skb, 1) = 0x1a; /* CTR, see spec:10.2.2.1 */
return nfc_hci_send_cmd_async(hdev, target->hci_reader_gate,
ST21NFCA_WR_XCHG_DATA, skb->data,
@ -797,7 +797,7 @@ static int st21nfca_hci_im_transceive(struct nfc_hci_dev *hdev,
info->async_cb = cb;
info->async_cb_context = cb_context;
*skb_push(skb, 1) = 0x17;
*(u8 *)skb_push(skb, 1) = 0x17;
return nfc_hci_send_cmd_async(hdev, target->hci_reader_gate,
ST21NFCA_WR_XCHG_DATA, skb->data,

View file

@ -315,10 +315,10 @@ int st21nfca_tm_send_dep_res(struct nfc_hci_dev *hdev, struct sk_buff *skb)
int r;
struct st21nfca_hci_info *info = nfc_hci_get_clientdata(hdev);
*skb_push(skb, 1) = info->dep_info.curr_nfc_dep_pni;
*skb_push(skb, 1) = ST21NFCA_NFCIP1_DEP_RES;
*skb_push(skb, 1) = ST21NFCA_NFCIP1_RES;
*skb_push(skb, 1) = skb->len;
*(u8 *)skb_push(skb, 1) = info->dep_info.curr_nfc_dep_pni;
*(u8 *)skb_push(skb, 1) = ST21NFCA_NFCIP1_DEP_RES;
*(u8 *)skb_push(skb, 1) = ST21NFCA_NFCIP1_RES;
*(u8 *)skb_push(skb, 1) = skb->len;
r = nfc_hci_send_event(hdev, ST21NFCA_RF_CARD_F_GATE,
ST21NFCA_EVT_SEND_DATA, skb->data, skb->len);
@ -466,7 +466,7 @@ static void st21nfca_im_send_psl_req(struct nfc_hci_dev *hdev, u8 did, u8 bsi,
psl_req->brs = (0x30 & bsi << 4) | (bri & 0x03);
psl_req->fsl = lri;
*skb_push(skb, 1) = info->dep_info.to | 0x10;
*(u8 *)skb_push(skb, 1) = info->dep_info.to | 0x10;
st21nfca_im_send_pdu(info, skb);
}
@ -568,7 +568,7 @@ int st21nfca_im_send_atr_req(struct nfc_hci_dev *hdev, u8 *gb, size_t gb_len)
}
atr_req->length = sizeof(struct st21nfca_atr_req) + hdev->gb_len;
*skb_push(skb, 1) = info->dep_info.to | 0x10; /* timeout */
*(u8 *)skb_push(skb, 1) = info->dep_info.to | 0x10; /* timeout */
info->async_cb_type = ST21NFCA_CB_TYPE_READER_F;
info->async_cb_context = info;
@ -629,10 +629,10 @@ static void st21nfca_im_recv_dep_res_cb(void *context, struct sk_buff *skb,
case ST21NFCA_NFC_DEP_PFB_SUPERVISOR_PDU:
pr_err("Received a SUPERVISOR PDU\n");
skb_pull(skb, size);
*skb_push(skb, 1) = ST21NFCA_NFCIP1_DEP_REQ;
*skb_push(skb, 1) = ST21NFCA_NFCIP1_REQ;
*skb_push(skb, 1) = skb->len;
*skb_push(skb, 1) = info->dep_info.to | 0x10;
*(u8 *)skb_push(skb, 1) = ST21NFCA_NFCIP1_DEP_REQ;
*(u8 *)skb_push(skb, 1) = ST21NFCA_NFCIP1_REQ;
*(u8 *)skb_push(skb, 1) = skb->len;
*(u8 *)skb_push(skb, 1) = info->dep_info.to | 0x10;
st21nfca_im_send_pdu(info, skb);
break;
@ -655,12 +655,12 @@ int st21nfca_im_send_dep_req(struct nfc_hci_dev *hdev, struct sk_buff *skb)
info->async_cb_context = info;
info->async_cb = st21nfca_im_recv_dep_res_cb;
*skb_push(skb, 1) = info->dep_info.curr_nfc_dep_pni;
*skb_push(skb, 1) = ST21NFCA_NFCIP1_DEP_REQ;
*skb_push(skb, 1) = ST21NFCA_NFCIP1_REQ;
*skb_push(skb, 1) = skb->len;
*(u8 *)skb_push(skb, 1) = info->dep_info.curr_nfc_dep_pni;
*(u8 *)skb_push(skb, 1) = ST21NFCA_NFCIP1_DEP_REQ;
*(u8 *)skb_push(skb, 1) = ST21NFCA_NFCIP1_REQ;
*(u8 *)skb_push(skb, 1) = skb->len;
*skb_push(skb, 1) = info->dep_info.to | 0x10;
*(u8 *)skb_push(skb, 1) = info->dep_info.to | 0x10;
return nfc_hci_send_cmd_async(hdev, ST21NFCA_RF_READER_F_GATE,
ST21NFCA_WR_XCHG_DATA,

View file

@ -171,7 +171,7 @@ static void st21nfca_hci_add_len_crc(struct sk_buff *skb)
u16 crc;
u8 tmp;
*skb_push(skb, 1) = 0;
*(u8 *)skb_push(skb, 1) = 0;
crc = crc_ccitt(0xffff, skb->data, skb->len);
crc = ~crc;
@ -216,7 +216,7 @@ static int st21nfca_hci_i2c_write(void *phy_id, struct sk_buff *skb)
/* add ST21NFCA_SOF_EOF on tail */
*(u8 *)skb_put(skb, 1) = ST21NFCA_SOF_EOF;
/* add ST21NFCA_SOF_EOF on head */
*skb_push(skb, 1) = ST21NFCA_SOF_EOF;
*(u8 *)skb_push(skb, 1) = ST21NFCA_SOF_EOF;
/*
* Compute byte stuffing