1
0
Fork 0
alistair23-linux/net/bluetooth
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
..
bnep net: remove MTU limits on a few ether_setup callers 2016-10-21 13:57:50 -04:00
cmtp networking: introduce and use skb_put_data() 2017-06-16 11:48:37 -04:00
hidp networking: introduce and use skb_put_data() 2017-06-16 11:48:37 -04:00
rfcomm networking: introduce and use skb_put_data() 2017-06-16 11:48:37 -04:00
6lowpan.c net: Fix inconsistent teardown and release of private netdev state. 2017-06-07 15:53:24 -04:00
Kconfig Bluetooth: convert smp and selftest to crypto kpp API 2017-04-25 04:53:42 +02:00
Makefile Bluetooth: convert smp and selftest to crypto kpp API 2017-04-25 04:53:42 +02:00
a2mp.c locking/atomic, kref: Add kref_read() 2017-01-14 11:37:18 +01:00
a2mp.h Bluetooth: Add BT_HS config option 2015-07-30 13:31:59 +02:00
af_bluetooth.c net: socket: mark socket protocol handler structs as const 2017-05-16 11:54:07 -04:00
amp.c Bluetooth: fix assignments on error variable err 2017-04-12 22:02:38 +02:00
amp.h Bluetooth: Add BT_HS config option 2015-07-30 13:31:59 +02:00
ecdh_helper.c Bluetooth: Delete error messages for failed memory allocations in two functions 2017-05-22 10:23:41 +02:00
ecdh_helper.h Bluetooth: convert smp and selftest to crypto kpp API 2017-04-25 04:53:42 +02:00
hci_conn.c Bluetooth: Fix using the correct source address type 2016-11-22 22:50:46 +01:00
hci_core.c networking: introduce and use skb_put_data() 2017-06-16 11:48:37 -04:00
hci_debugfs.c Bluetooth: Add debugfs fields for hardware and firmware info 2016-07-18 09:33:28 +03:00
hci_debugfs.h Bluetooth: Provide option to enable/disable debugfs information 2015-02-15 18:54:13 +02:00
hci_event.c Bluetooth: fix spelling mistake: "advetising" -> "advertising" 2017-02-16 17:39:35 +01:00
hci_request.c networking: introduce and use skb_put_data() 2017-06-16 11:48:37 -04:00
hci_request.h Bluetooth: Fix append max 11 bytes of name to scan rsp data 2016-10-19 18:42:37 +02:00
hci_sock.c networking: introduce and use skb_put_data() 2017-06-16 11:48:37 -04:00
hci_sysfs.c Bluetooth: Remove controller device attributes 2016-07-09 21:37:11 +03:00
l2cap_core.c networking: introduce and use skb_put_data() 2017-06-16 11:48:37 -04:00
l2cap_sock.c net: Work around lockdep limitation in sockets that use sockets 2017-03-09 18:23:27 -08:00
leds.c Bluetooth: Add combined LED trigger for controller power 2016-09-19 20:19:34 +02:00
leds.h Bluetooth: Add combined LED trigger for controller power 2016-09-19 20:19:34 +02:00
lib.c Bluetooth: Add BT_WARN and bt_dev_warn logging macros 2015-09-24 16:25:44 +02:00
mgmt.c Bluetooth: Fix append max 11 bytes of name to scan rsp data 2016-10-19 18:42:37 +02:00
mgmt_util.c networking: introduce and use skb_put_data() 2017-06-16 11:48:37 -04:00
mgmt_util.h Bluetooth: Add generic mgmt helper API 2015-03-17 18:03:08 +01:00
sco.c net: Work around lockdep limitation in sockets that use sockets 2017-03-09 18:23:27 -08:00
selftest.c Bluetooth: allocate data for kpp on heap 2017-04-30 12:22:05 +02:00
selftest.h Bluetooth: Add support for self testing framework 2014-12-30 08:53:55 +02:00
smp.c Bluetooth: use constant time memory comparison for secret values 2017-06-10 15:45:40 +02:00
smp.h Bluetooth: SMP: Add support for H7 crypto function and CT2 auth flag 2016-12-08 07:50:24 +01:00