aboutsummaryrefslogtreecommitdiffstats
path: root/net/802
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2017-06-16 08:29:21 -0400
committerDavid S. Miller <davem@davemloft.net>2017-06-16 11:48:39 -0400
commit4df864c1d9afb46e2461a9f808d9f11a42d31bad (patch)
tree07e7b3d16b161e0d199c5b8116df277798566e4f /net/802
parent59ae1d127ac0ae404baf414c434ba2651b793f46 (diff)
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>
Diffstat (limited to 'net/802')
-rw-r--r--net/802/garp.c6
-rw-r--r--net/802/mrp.c11
2 files changed, 8 insertions, 9 deletions
diff --git a/net/802/garp.c b/net/802/garp.c
index b38ee6dcba45..a9a266569293 100644
--- a/net/802/garp.c
+++ b/net/802/garp.c
@@ -221,7 +221,7 @@ static int garp_pdu_init(struct garp_applicant *app)
221 skb->protocol = htons(ETH_P_802_2); 221 skb->protocol = htons(ETH_P_802_2);
222 skb_reserve(skb, LL_RESERVED_SPACE(app->dev) + LLC_RESERVE); 222 skb_reserve(skb, LL_RESERVED_SPACE(app->dev) + LLC_RESERVE);
223 223
224 gp = (struct garp_pdu_hdr *)__skb_put(skb, sizeof(*gp)); 224 gp = __skb_put(skb, sizeof(*gp));
225 put_unaligned(htons(GARP_PROTOCOL_ID), &gp->protocol); 225 put_unaligned(htons(GARP_PROTOCOL_ID), &gp->protocol);
226 226
227 app->pdu = skb; 227 app->pdu = skb;
@@ -268,7 +268,7 @@ static int garp_pdu_append_msg(struct garp_applicant *app, u8 attrtype)
268 268
269 if (skb_tailroom(app->pdu) < sizeof(*gm)) 269 if (skb_tailroom(app->pdu) < sizeof(*gm))
270 return -1; 270 return -1;
271 gm = (struct garp_msg_hdr *)__skb_put(app->pdu, sizeof(*gm)); 271 gm = __skb_put(app->pdu, sizeof(*gm));
272 gm->attrtype = attrtype; 272 gm->attrtype = attrtype;
273 garp_cb(app->pdu)->cur_type = attrtype; 273 garp_cb(app->pdu)->cur_type = attrtype;
274 return 0; 274 return 0;
@@ -299,7 +299,7 @@ again:
299 len = sizeof(*ga) + attr->dlen; 299 len = sizeof(*ga) + attr->dlen;
300 if (skb_tailroom(app->pdu) < len) 300 if (skb_tailroom(app->pdu) < len)
301 goto queue; 301 goto queue;
302 ga = (struct garp_attr_hdr *)__skb_put(app->pdu, len); 302 ga = __skb_put(app->pdu, len);
303 ga->len = len; 303 ga->len = len;
304 ga->event = event; 304 ga->event = event;
305 memcpy(ga->data, attr->data, attr->dlen); 305 memcpy(ga->data, attr->data, attr->dlen);
diff --git a/net/802/mrp.c b/net/802/mrp.c
index 72db2785ef2c..be4dd3165347 100644
--- a/net/802/mrp.c
+++ b/net/802/mrp.c
@@ -311,7 +311,7 @@ static int mrp_pdu_init(struct mrp_applicant *app)
311 skb_reset_network_header(skb); 311 skb_reset_network_header(skb);
312 skb_reset_transport_header(skb); 312 skb_reset_transport_header(skb);
313 313
314 ph = (struct mrp_pdu_hdr *)__skb_put(skb, sizeof(*ph)); 314 ph = __skb_put(skb, sizeof(*ph));
315 ph->version = app->app->version; 315 ph->version = app->app->version;
316 316
317 app->pdu = skb; 317 app->pdu = skb;
@@ -324,7 +324,7 @@ static int mrp_pdu_append_end_mark(struct mrp_applicant *app)
324 324
325 if (skb_tailroom(app->pdu) < sizeof(*endmark)) 325 if (skb_tailroom(app->pdu) < sizeof(*endmark))
326 return -1; 326 return -1;
327 endmark = (__be16 *)__skb_put(app->pdu, sizeof(*endmark)); 327 endmark = __skb_put(app->pdu, sizeof(*endmark));
328 put_unaligned(MRP_END_MARK, endmark); 328 put_unaligned(MRP_END_MARK, endmark);
329 return 0; 329 return 0;
330} 330}
@@ -368,7 +368,7 @@ static int mrp_pdu_append_msg_hdr(struct mrp_applicant *app,
368 368
369 if (skb_tailroom(app->pdu) < sizeof(*mh)) 369 if (skb_tailroom(app->pdu) < sizeof(*mh))
370 return -1; 370 return -1;
371 mh = (struct mrp_msg_hdr *)__skb_put(app->pdu, sizeof(*mh)); 371 mh = __skb_put(app->pdu, sizeof(*mh));
372 mh->attrtype = attrtype; 372 mh->attrtype = attrtype;
373 mh->attrlen = attrlen; 373 mh->attrlen = attrlen;
374 mrp_cb(app->pdu)->mh = mh; 374 mrp_cb(app->pdu)->mh = mh;
@@ -382,8 +382,7 @@ static int mrp_pdu_append_vecattr_hdr(struct mrp_applicant *app,
382 382
383 if (skb_tailroom(app->pdu) < sizeof(*vah) + attrlen) 383 if (skb_tailroom(app->pdu) < sizeof(*vah) + attrlen)
384 return -1; 384 return -1;
385 vah = (struct mrp_vecattr_hdr *)__skb_put(app->pdu, 385 vah = __skb_put(app->pdu, sizeof(*vah) + attrlen);
386 sizeof(*vah) + attrlen);
387 put_unaligned(0, &vah->lenflags); 386 put_unaligned(0, &vah->lenflags);
388 memcpy(vah->firstattrvalue, firstattrvalue, attrlen); 387 memcpy(vah->firstattrvalue, firstattrvalue, attrlen);
389 mrp_cb(app->pdu)->vah = vah; 388 mrp_cb(app->pdu)->vah = vah;
@@ -435,7 +434,7 @@ again:
435 if (!pos) { 434 if (!pos) {
436 if (skb_tailroom(app->pdu) < sizeof(u8)) 435 if (skb_tailroom(app->pdu) < sizeof(u8))
437 goto queue; 436 goto queue;
438 vaevents = (u8 *)__skb_put(app->pdu, sizeof(u8)); 437 vaevents = __skb_put(app->pdu, sizeof(u8));
439 } else { 438 } else {
440 vaevents = (u8 *)(skb_tail_pointer(app->pdu) - sizeof(u8)); 439 vaevents = (u8 *)(skb_tail_pointer(app->pdu) - sizeof(u8));
441 } 440 }