linux/drivers/staging/gdm724x
Johannes Berg 59ae1d127a networking: introduce and use skb_put_data()
A common pattern with skb_put() is to just want to memcpy()
some data into the new space, introduce skb_put_data() for
this.

An spatch similar to the one for skb_put_zero() converts many
of the places using it:

    @@
    identifier p, p2;
    expression len, skb, data;
    type t, t2;
    @@
    (
    -p = skb_put(skb, len);
    +p = skb_put_data(skb, data, len);
    |
    -p = (t)skb_put(skb, len);
    +p = skb_put_data(skb, data, len);
    )
    (
    p2 = (t2)p;
    -memcpy(p2, data, len);
    |
    -memcpy(p, data, len);
    )

    @@
    type t, t2;
    identifier p, p2;
    expression skb, data;
    @@
    t *p;
    ...
    (
    -p = skb_put(skb, sizeof(t));
    +p = skb_put_data(skb, data, sizeof(t));
    |
    -p = (t *)skb_put(skb, sizeof(t));
    +p = skb_put_data(skb, data, sizeof(t));
    )
    (
    p2 = (t2)p;
    -memcpy(p2, data, sizeof(*p));
    |
    -memcpy(p, data, sizeof(*p));
    )

    @@
    expression skb, len, data;
    @@
    -memcpy(skb_put(skb, len), data, len);
    +skb_put_data(skb, data, len);

(again, manually post-processed to retain some comments)

Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-06-16 11:48:37 -04:00
..
gdm_endian.c staging: gdm724x: update HCI structs with new bitwise types 2017-01-05 18:50:05 +01:00
gdm_endian.h staging: gdm724x: update HCI structs with new bitwise types 2017-01-05 18:50:05 +01:00
gdm_lte.c networking: introduce and use skb_put_data() 2017-06-16 11:48:37 -04:00
gdm_lte.h staging: gdm724x: fix checkpatch.pl camelCase warning 2017-03-16 11:48:59 +09:00
gdm_mux.c staging: gdm724x: gdm_mux: fix use-after-free on module unload 2017-04-28 12:32:49 +02:00
gdm_mux.h staging: gdm724x: Add spaces around the '*' operator 2016-09-13 14:51:53 +02:00
gdm_tty.c staging: gdm724x: Replace ternary operator with min macro 2017-03-09 18:50:05 +01:00
gdm_tty.h staging: gdm724x: Remove one blank line in sequence 2016-11-29 21:57:15 +01:00
gdm_usb.c staging: gdm724x: gdm_usb: Remove ignored value 2016-08-21 18:04:43 +02:00
gdm_usb.h staging: gdm724x: Add spaces around the '*' operator 2016-09-13 14:51:53 +02:00
hci_packet.h staging: gdm724x: update HCI structs with new bitwise types 2017-01-05 18:50:05 +01:00
hci.h
Kconfig
Makefile
netlink_k.c staging: gdm724x: Replace semaphore netlink with mutex 2016-08-21 18:04:43 +02:00
netlink_k.h staging: gdm724x: Align parameters to parenthesis 2016-11-29 21:57:14 +01:00
TODO