mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-31 04:01:48 -04:00
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 <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
This commit is contained in:
parent
59ae1d127a
commit
4df864c1d9
145 changed files with 486 additions and 547 deletions
|
|
@ -1082,7 +1082,7 @@ static int capinc_tty_put_char(struct tty_struct *tty, unsigned char ch)
|
|||
skb = mp->outskb;
|
||||
if (skb) {
|
||||
if (skb_tailroom(skb) > 0) {
|
||||
*(skb_put(skb, 1)) = ch;
|
||||
*(u8 *)skb_put(skb, 1) = ch;
|
||||
goto unlock_out;
|
||||
}
|
||||
mp->outskb = NULL;
|
||||
|
|
@ -1094,7 +1094,7 @@ static int capinc_tty_put_char(struct tty_struct *tty, unsigned char ch)
|
|||
skb = alloc_skb(CAPI_DATA_B3_REQ_LEN + CAPI_MAX_BLKSIZE, GFP_ATOMIC);
|
||||
if (skb) {
|
||||
skb_reserve(skb, CAPI_DATA_B3_REQ_LEN);
|
||||
*(skb_put(skb, 1)) = ch;
|
||||
*(u8 *)skb_put(skb, 1) = ch;
|
||||
mp->outskb = skb;
|
||||
} else {
|
||||
printk(KERN_ERR "capinc_put_char: char %u lost\n", ch);
|
||||
|
|
|
|||
|
|
@ -264,7 +264,7 @@ byte_stuff:
|
|||
/* skip remainder of packet */
|
||||
bcs->rx_skb = skb = NULL;
|
||||
} else {
|
||||
*__skb_put(skb, 1) = c;
|
||||
*(u8 *)__skb_put(skb, 1) = c;
|
||||
fcs = crc_ccitt_byte(fcs, c);
|
||||
}
|
||||
}
|
||||
|
|
@ -315,7 +315,7 @@ static unsigned iraw_loop(unsigned numbytes, struct inbuf_t *inbuf)
|
|||
|
||||
/* regular data byte: append to current skb */
|
||||
inputstate |= INS_have_data;
|
||||
*__skb_put(skb, 1) = bitrev8(c);
|
||||
*(u8 *)__skb_put(skb, 1) = bitrev8(c);
|
||||
}
|
||||
|
||||
/* pass data up */
|
||||
|
|
@ -492,33 +492,33 @@ static struct sk_buff *HDLC_Encode(struct sk_buff *skb)
|
|||
hdlc_skb->mac_len = skb->mac_len;
|
||||
|
||||
/* Add flag sequence in front of everything.. */
|
||||
*(skb_put(hdlc_skb, 1)) = PPP_FLAG;
|
||||
*(u8 *)skb_put(hdlc_skb, 1) = PPP_FLAG;
|
||||
|
||||
/* Perform byte stuffing while copying data. */
|
||||
while (skb->len--) {
|
||||
if (muststuff(*skb->data)) {
|
||||
*(skb_put(hdlc_skb, 1)) = PPP_ESCAPE;
|
||||
*(skb_put(hdlc_skb, 1)) = (*skb->data++) ^ PPP_TRANS;
|
||||
*(u8 *)skb_put(hdlc_skb, 1) = PPP_ESCAPE;
|
||||
*(u8 *)skb_put(hdlc_skb, 1) = (*skb->data++) ^ PPP_TRANS;
|
||||
} else
|
||||
*(skb_put(hdlc_skb, 1)) = *skb->data++;
|
||||
*(u8 *)skb_put(hdlc_skb, 1) = *skb->data++;
|
||||
}
|
||||
|
||||
/* Finally add FCS (byte stuffed) and flag sequence */
|
||||
c = (fcs & 0x00ff); /* least significant byte first */
|
||||
if (muststuff(c)) {
|
||||
*(skb_put(hdlc_skb, 1)) = PPP_ESCAPE;
|
||||
*(u8 *)skb_put(hdlc_skb, 1) = PPP_ESCAPE;
|
||||
c ^= PPP_TRANS;
|
||||
}
|
||||
*(skb_put(hdlc_skb, 1)) = c;
|
||||
*(u8 *)skb_put(hdlc_skb, 1) = c;
|
||||
|
||||
c = ((fcs >> 8) & 0x00ff);
|
||||
if (muststuff(c)) {
|
||||
*(skb_put(hdlc_skb, 1)) = PPP_ESCAPE;
|
||||
*(u8 *)skb_put(hdlc_skb, 1) = PPP_ESCAPE;
|
||||
c ^= PPP_TRANS;
|
||||
}
|
||||
*(skb_put(hdlc_skb, 1)) = c;
|
||||
*(u8 *)skb_put(hdlc_skb, 1) = c;
|
||||
|
||||
*(skb_put(hdlc_skb, 1)) = PPP_FLAG;
|
||||
*(u8 *)skb_put(hdlc_skb, 1) = PPP_FLAG;
|
||||
|
||||
dev_kfree_skb_any(skb);
|
||||
return hdlc_skb;
|
||||
|
|
@ -561,8 +561,8 @@ static struct sk_buff *iraw_encode(struct sk_buff *skb)
|
|||
while (len--) {
|
||||
c = bitrev8(*cp++);
|
||||
if (c == DLE_FLAG)
|
||||
*(skb_put(iraw_skb, 1)) = c;
|
||||
*(skb_put(iraw_skb, 1)) = c;
|
||||
*(u8 *)skb_put(iraw_skb, 1) = c;
|
||||
*(u8 *)skb_put(iraw_skb, 1) = c;
|
||||
}
|
||||
dev_kfree_skb_any(skb);
|
||||
return iraw_skb;
|
||||
|
|
|
|||
|
|
@ -511,7 +511,7 @@ static inline void hdlc_putbyte(unsigned char c, struct bc_state *bcs)
|
|||
bcs->rx_skb = NULL;
|
||||
return;
|
||||
}
|
||||
*__skb_put(bcs->rx_skb, 1) = c;
|
||||
*(u8 *)__skb_put(bcs->rx_skb, 1) = c;
|
||||
}
|
||||
|
||||
/* hdlc_flush
|
||||
|
|
|
|||
|
|
@ -462,7 +462,7 @@ isdn_audio_goertzel(int *sample, modem_info *info)
|
|||
info->line);
|
||||
return;
|
||||
}
|
||||
result = (int *) skb_put(skb, sizeof(int) * NCOEFF);
|
||||
result = skb_put(skb, sizeof(int) * NCOEFF);
|
||||
for (k = 0; k < NCOEFF; k++) {
|
||||
sk = sk1 = sk2 = 0;
|
||||
for (n = 0; n < DTMF_NPOINTS; n++) {
|
||||
|
|
@ -672,7 +672,7 @@ isdn_audio_put_dle_code(modem_info *info, u_char code)
|
|||
info->line);
|
||||
return;
|
||||
}
|
||||
p = (char *) skb_put(skb, 2);
|
||||
p = skb_put(skb, 2);
|
||||
p[0] = 0x10;
|
||||
p[1] = code;
|
||||
ISDN_AUDIO_SKB_DLECOUNT(skb) = 0;
|
||||
|
|
|
|||
|
|
@ -472,7 +472,7 @@ static int bsd_compress(void *state, struct sk_buff *skb_in, struct sk_buff *skb
|
|||
accm |= ((ent) << bitno); \
|
||||
do { \
|
||||
if (skb_out && skb_tailroom(skb_out) > 0) \
|
||||
*(skb_put(skb_out, 1)) = (unsigned char)(accm >> 24); \
|
||||
*(u8 *)skb_put(skb_out, 1) = (u8)(accm >> 24); \
|
||||
accm <<= 8; \
|
||||
bitno += 8; \
|
||||
} while (bitno <= 24); \
|
||||
|
|
@ -602,7 +602,7 @@ static int bsd_compress(void *state, struct sk_buff *skb_in, struct sk_buff *skb
|
|||
* Do not emit a completely useless byte of ones.
|
||||
*/
|
||||
if (bitno < 32 && skb_out && skb_tailroom(skb_out) > 0)
|
||||
*(skb_put(skb_out, 1)) = (unsigned char)((accm | (0xff << (bitno - 8))) >> 24);
|
||||
*(u8 *)skb_put(skb_out, 1) = (unsigned char)((accm | (0xff << (bitno - 8))) >> 24);
|
||||
|
||||
/*
|
||||
* Increase code size if we would have without the packet
|
||||
|
|
@ -698,7 +698,7 @@ static int bsd_decompress(void *state, struct sk_buff *skb_in, struct sk_buff *s
|
|||
db->bytes_out += ilen;
|
||||
|
||||
if (skb_tailroom(skb_out) > 0)
|
||||
*(skb_put(skb_out, 1)) = 0;
|
||||
*(u8 *)skb_put(skb_out, 1) = 0;
|
||||
else
|
||||
return DECOMP_ERR_NOMEM;
|
||||
|
||||
|
|
@ -816,7 +816,7 @@ static int bsd_decompress(void *state, struct sk_buff *skb_in, struct sk_buff *s
|
|||
#endif
|
||||
|
||||
if (extra) /* the KwKwK case again */
|
||||
*(skb_put(skb_out, 1)) = finchar;
|
||||
*(u8 *)skb_put(skb_out, 1) = finchar;
|
||||
|
||||
/*
|
||||
* If not first code in a packet, and
|
||||
|
|
|
|||
|
|
@ -224,7 +224,7 @@ static int isdn_x25iface_connect_ind(struct concap_proto *cprot)
|
|||
|
||||
skb = dev_alloc_skb(1);
|
||||
if (skb) {
|
||||
*(skb_put(skb, 1)) = X25_IFACE_CONNECT;
|
||||
*(u8 *)skb_put(skb, 1) = X25_IFACE_CONNECT;
|
||||
skb->protocol = x25_type_trans(skb, cprot->net_dev);
|
||||
netif_rx(skb);
|
||||
return 0;
|
||||
|
|
@ -253,7 +253,7 @@ static int isdn_x25iface_disconn_ind(struct concap_proto *cprot)
|
|||
*state_p = WAN_DISCONNECTED;
|
||||
skb = dev_alloc_skb(1);
|
||||
if (skb) {
|
||||
*(skb_put(skb, 1)) = X25_IFACE_DISCONNECT;
|
||||
*(u8 *)skb_put(skb, 1) = X25_IFACE_DISCONNECT;
|
||||
skb->protocol = x25_type_trans(skb, cprot->net_dev);
|
||||
netif_rx(skb);
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Reference in a new issue