diff options
| author | Johannes Berg <johannes.berg@intel.com> | 2017-06-16 08:29:23 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2017-06-16 11:48:40 -0400 |
| commit | d58ff35122847a83ba55394e2ae3a1527b6febf5 (patch) | |
| tree | e1ecf758e86519922c403f1aa88f19ef25a554ad /net/bluetooth | |
| parent | af72868b9070d1b843c829f0d0d0b22c04a20815 (diff) | |
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>
Diffstat (limited to 'net/bluetooth')
| -rw-r--r-- | net/bluetooth/hci_sock.c | 12 | ||||
| -rw-r--r-- | net/bluetooth/mgmt_util.c | 2 | ||||
| -rw-r--r-- | net/bluetooth/rfcomm/core.c | 4 |
3 files changed, 9 insertions, 9 deletions
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c index 1301a8786d8d..cdb5c1a7481e 100644 --- a/net/bluetooth/hci_sock.c +++ b/net/bluetooth/hci_sock.c | |||
| @@ -332,7 +332,7 @@ void hci_send_to_monitor(struct hci_dev *hdev, struct sk_buff *skb) | |||
| 332 | return; | 332 | return; |
| 333 | 333 | ||
| 334 | /* Put header before the data */ | 334 | /* Put header before the data */ |
| 335 | hdr = (void *)skb_push(skb_copy, HCI_MON_HDR_SIZE); | 335 | hdr = skb_push(skb_copy, HCI_MON_HDR_SIZE); |
| 336 | hdr->opcode = opcode; | 336 | hdr->opcode = opcode; |
| 337 | hdr->index = cpu_to_le16(hdev->id); | 337 | hdr->index = cpu_to_le16(hdev->id); |
| 338 | hdr->len = cpu_to_le16(skb->len); | 338 | hdr->len = cpu_to_le16(skb->len); |
| @@ -383,7 +383,7 @@ void hci_send_monitor_ctrl_event(struct hci_dev *hdev, u16 event, | |||
| 383 | 383 | ||
| 384 | skb->tstamp = tstamp; | 384 | skb->tstamp = tstamp; |
| 385 | 385 | ||
| 386 | hdr = (void *)skb_push(skb, HCI_MON_HDR_SIZE); | 386 | hdr = skb_push(skb, HCI_MON_HDR_SIZE); |
| 387 | hdr->opcode = cpu_to_le16(HCI_MON_CTRL_EVENT); | 387 | hdr->opcode = cpu_to_le16(HCI_MON_CTRL_EVENT); |
| 388 | hdr->index = index; | 388 | hdr->index = index; |
| 389 | hdr->len = cpu_to_le16(skb->len - HCI_MON_HDR_SIZE); | 389 | hdr->len = cpu_to_le16(skb->len - HCI_MON_HDR_SIZE); |
| @@ -467,7 +467,7 @@ static struct sk_buff *create_monitor_event(struct hci_dev *hdev, int event) | |||
| 467 | 467 | ||
| 468 | __net_timestamp(skb); | 468 | __net_timestamp(skb); |
| 469 | 469 | ||
| 470 | hdr = (void *)skb_push(skb, HCI_MON_HDR_SIZE); | 470 | hdr = skb_push(skb, HCI_MON_HDR_SIZE); |
| 471 | hdr->opcode = opcode; | 471 | hdr->opcode = opcode; |
| 472 | hdr->index = cpu_to_le16(hdev->id); | 472 | hdr->index = cpu_to_le16(hdev->id); |
| 473 | hdr->len = cpu_to_le16(skb->len - HCI_MON_HDR_SIZE); | 473 | hdr->len = cpu_to_le16(skb->len - HCI_MON_HDR_SIZE); |
| @@ -522,7 +522,7 @@ static struct sk_buff *create_monitor_ctrl_open(struct sock *sk) | |||
| 522 | 522 | ||
| 523 | __net_timestamp(skb); | 523 | __net_timestamp(skb); |
| 524 | 524 | ||
| 525 | hdr = (void *)skb_push(skb, HCI_MON_HDR_SIZE); | 525 | hdr = skb_push(skb, HCI_MON_HDR_SIZE); |
| 526 | hdr->opcode = cpu_to_le16(HCI_MON_CTRL_OPEN); | 526 | hdr->opcode = cpu_to_le16(HCI_MON_CTRL_OPEN); |
| 527 | if (hci_pi(sk)->hdev) | 527 | if (hci_pi(sk)->hdev) |
| 528 | hdr->index = cpu_to_le16(hci_pi(sk)->hdev->id); | 528 | hdr->index = cpu_to_le16(hci_pi(sk)->hdev->id); |
| @@ -560,7 +560,7 @@ static struct sk_buff *create_monitor_ctrl_close(struct sock *sk) | |||
| 560 | 560 | ||
| 561 | __net_timestamp(skb); | 561 | __net_timestamp(skb); |
| 562 | 562 | ||
| 563 | hdr = (void *)skb_push(skb, HCI_MON_HDR_SIZE); | 563 | hdr = skb_push(skb, HCI_MON_HDR_SIZE); |
| 564 | hdr->opcode = cpu_to_le16(HCI_MON_CTRL_CLOSE); | 564 | hdr->opcode = cpu_to_le16(HCI_MON_CTRL_CLOSE); |
| 565 | if (hci_pi(sk)->hdev) | 565 | if (hci_pi(sk)->hdev) |
| 566 | hdr->index = cpu_to_le16(hci_pi(sk)->hdev->id); | 566 | hdr->index = cpu_to_le16(hci_pi(sk)->hdev->id); |
| @@ -590,7 +590,7 @@ static struct sk_buff *create_monitor_ctrl_command(struct sock *sk, u16 index, | |||
| 590 | 590 | ||
| 591 | __net_timestamp(skb); | 591 | __net_timestamp(skb); |
| 592 | 592 | ||
| 593 | hdr = (void *)skb_push(skb, HCI_MON_HDR_SIZE); | 593 | hdr = skb_push(skb, HCI_MON_HDR_SIZE); |
| 594 | hdr->opcode = cpu_to_le16(HCI_MON_CTRL_COMMAND); | 594 | hdr->opcode = cpu_to_le16(HCI_MON_CTRL_COMMAND); |
| 595 | hdr->index = cpu_to_le16(index); | 595 | hdr->index = cpu_to_le16(index); |
| 596 | hdr->len = cpu_to_le16(skb->len - HCI_MON_HDR_SIZE); | 596 | hdr->len = cpu_to_le16(skb->len - HCI_MON_HDR_SIZE); |
diff --git a/net/bluetooth/mgmt_util.c b/net/bluetooth/mgmt_util.c index d057113e0d4b..0d0a6d77b9e8 100644 --- a/net/bluetooth/mgmt_util.c +++ b/net/bluetooth/mgmt_util.c | |||
| @@ -48,7 +48,7 @@ static struct sk_buff *create_monitor_ctrl_event(__le16 index, u32 cookie, | |||
| 48 | 48 | ||
| 49 | __net_timestamp(skb); | 49 | __net_timestamp(skb); |
| 50 | 50 | ||
| 51 | hdr = (void *)skb_push(skb, HCI_MON_HDR_SIZE); | 51 | hdr = skb_push(skb, HCI_MON_HDR_SIZE); |
| 52 | hdr->opcode = cpu_to_le16(HCI_MON_CTRL_EVENT); | 52 | hdr->opcode = cpu_to_le16(HCI_MON_CTRL_EVENT); |
| 53 | hdr->index = index; | 53 | hdr->index = index; |
| 54 | hdr->len = cpu_to_le16(skb->len - HCI_MON_HDR_SIZE); | 54 | hdr->len = cpu_to_le16(skb->len - HCI_MON_HDR_SIZE); |
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c index 1a9b906c5a35..4a0b41d75c84 100644 --- a/net/bluetooth/rfcomm/core.c +++ b/net/bluetooth/rfcomm/core.c | |||
| @@ -1149,10 +1149,10 @@ static void rfcomm_make_uih(struct sk_buff *skb, u8 addr) | |||
| 1149 | u8 *crc; | 1149 | u8 *crc; |
| 1150 | 1150 | ||
| 1151 | if (len > 127) { | 1151 | if (len > 127) { |
| 1152 | hdr = (void *) skb_push(skb, 4); | 1152 | hdr = skb_push(skb, 4); |
| 1153 | put_unaligned(cpu_to_le16(__len16(len)), (__le16 *) &hdr->len); | 1153 | put_unaligned(cpu_to_le16(__len16(len)), (__le16 *) &hdr->len); |
| 1154 | } else { | 1154 | } else { |
| 1155 | hdr = (void *) skb_push(skb, 3); | 1155 | hdr = skb_push(skb, 3); |
| 1156 | hdr->len = __len8(len); | 1156 | hdr->len = __len8(len); |
| 1157 | } | 1157 | } |
| 1158 | hdr->addr = addr; | 1158 | hdr->addr = addr; |
