networking: introduce and use skb_put_data()
authorJohannes Berg <johannes.berg@intel.com>
Fri, 16 Jun 2017 12:29:20 +0000 (14:29 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 16 Jun 2017 15:48:37 +0000 (11:48 -0400)
commit59ae1d127ac0ae404baf414c434ba2651b793f46
tree043e71496aa7a7db86bcc8219a3a51f533aac982
parentb080db585384b9f037e015c0c28d1ad33be41dfc
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>
252 files changed:
drivers/atm/fore200e.c
drivers/atm/he.c
drivers/atm/idt77252.c
drivers/atm/solos-pci.c
drivers/bluetooth/bfusb.c
drivers/bluetooth/bluecard_cs.c
drivers/bluetooth/btmrvl_main.c
drivers/bluetooth/btqcomsmd.c
drivers/bluetooth/btusb.c
drivers/bluetooth/hci_bcsp.c
drivers/bluetooth/hci_h4.c
drivers/bluetooth/hci_h5.c
drivers/bluetooth/hci_intel.c
drivers/bluetooth/hci_ll.c
drivers/bluetooth/hci_mrvl.c
drivers/bluetooth/hci_qca.c
drivers/char/pcmcia/synclink_cs.c
drivers/firewire/net.c
drivers/isdn/capi/capi.c
drivers/isdn/capi/capidrv.c
drivers/isdn/hardware/avm/b1.c
drivers/isdn/hardware/avm/b1dma.c
drivers/isdn/hardware/avm/c4.c
drivers/isdn/hardware/avm/t1isa.c
drivers/isdn/hardware/mISDN/hfcmulti.c
drivers/isdn/hardware/mISDN/hfcsusb.c
drivers/isdn/hisax/amd7930_fn.c
drivers/isdn/hisax/avm_pci.c
drivers/isdn/hisax/diva.c
drivers/isdn/hisax/elsa_ser.c
drivers/isdn/hisax/hfc_usb.c
drivers/isdn/hisax/hisax_fcpcipnp.c
drivers/isdn/hisax/hisax_isac.c
drivers/isdn/hisax/hscx_irq.c
drivers/isdn/hisax/icc.c
drivers/isdn/hisax/ipacx.c
drivers/isdn/hisax/isac.c
drivers/isdn/hisax/isar.c
drivers/isdn/hisax/isdnl2.c
drivers/isdn/hisax/jade_irq.c
drivers/isdn/hisax/l3_1tr6.c
drivers/isdn/hisax/l3dss1.c
drivers/isdn/hisax/l3ni1.c
drivers/isdn/hisax/netjet.c
drivers/isdn/hisax/st5481_usb.c
drivers/isdn/hisax/w6692.c
drivers/isdn/hysdn/hycapi.c
drivers/isdn/hysdn/hysdn_net.c
drivers/isdn/i4l/isdn_ppp.c
drivers/isdn/i4l/isdn_tty.c
drivers/isdn/i4l/isdn_v110.c
drivers/isdn/isdnloop/isdnloop.c
drivers/isdn/mISDN/dsp_cmx.c
drivers/isdn/mISDN/layer2.c
drivers/isdn/mISDN/tei.c
drivers/media/dvb-core/dvb_net.c
drivers/media/radio/wl128x/fmdrv_common.c
drivers/misc/ti-st/st_core.c
drivers/misc/ti-st/st_kim.c
drivers/net/bonding/bond_alb.c
drivers/net/caif/caif_hsi.c
drivers/net/caif/caif_serial.c
drivers/net/caif/caif_spi.c
drivers/net/caif/caif_virtio.c
drivers/net/can/slcan.c
drivers/net/ethernet/3com/3c515.c
drivers/net/ethernet/3com/3c59x.c
drivers/net/ethernet/aeroflex/greth.c
drivers/net/ethernet/agere/et131x.c
drivers/net/ethernet/apple/macmace.c
drivers/net/ethernet/aurora/nb8800.c
drivers/net/ethernet/cadence/macb.c
drivers/net/ethernet/cavium/liquidio/octeon_network.h
drivers/net/ethernet/cirrus/cs89x0.c
drivers/net/ethernet/dec/tulip/de4x5.c
drivers/net/ethernet/dec/tulip/interrupt.c
drivers/net/ethernet/dec/tulip/uli526x.c
drivers/net/ethernet/ec_bhf.c
drivers/net/ethernet/fealnx.c
drivers/net/ethernet/i825xx/82596.c
drivers/net/ethernet/i825xx/lib82596.c
drivers/net/ethernet/intel/e1000/e1000_main.c
drivers/net/ethernet/marvell/mvneta.c
drivers/net/ethernet/micrel/ksz884x.c
drivers/net/ethernet/nxp/lpc_eth.c
drivers/net/ethernet/qlogic/qede/qede_fp.c
drivers/net/ethernet/qlogic/qlge/qlge_main.c
drivers/net/ethernet/silan/sc92031.c
drivers/net/fjes/fjes_main.c
drivers/net/hamradio/mkiss.c
drivers/net/hippi/rrunner.c
drivers/net/hyperv/netvsc_drv.c
drivers/net/ieee802154/at86rf230.c
drivers/net/ieee802154/ca8210.c
drivers/net/ieee802154/mrf24j40.c
drivers/net/irda/smsc-ircc2.c
drivers/net/irda/vlsi_ir.c
drivers/net/ppp/ppp_async.c
drivers/net/ppp/ppp_synctty.c
drivers/net/slip/slip.c
drivers/net/usb/asix_common.c
drivers/net/usb/cdc-phonet.c
drivers/net/usb/cdc_mbim.c
drivers/net/usb/cdc_ncm.c
drivers/net/usb/gl620a.c
drivers/net/usb/hso.c
drivers/net/usb/ipheth.c
drivers/net/usb/lg-vl600.c
drivers/net/usb/qmi_wwan.c
drivers/net/virtio_net.c
drivers/net/wan/farsync.c
drivers/net/wan/hdlc_ppp.c
drivers/net/wan/x25_asy.c
drivers/net/wimax/i2400m/netdev.c
drivers/net/wireless/admtek/adm8211.c
drivers/net/wireless/ath/ath10k/mac.c
drivers/net/wireless/ath/ath10k/wmi.c
drivers/net/wireless/ath/ath9k/channel.c
drivers/net/wireless/ath/ath9k/wmi.c
drivers/net/wireless/ath/carl9170/rx.c
drivers/net/wireless/ath/wil6210/wmi.c
drivers/net/wireless/atmel/atmel.c
drivers/net/wireless/broadcom/b43legacy/dma.c
drivers/net/wireless/intel/ipw2x00/ipw2200.c
drivers/net/wireless/intel/ipw2x00/libipw_tx.c
drivers/net/wireless/intel/iwlegacy/3945.c
drivers/net/wireless/intel/iwlegacy/4965-mac.c
drivers/net/wireless/intel/iwlwifi/dvm/rx.c
drivers/net/wireless/intel/iwlwifi/dvm/tx.c
drivers/net/wireless/intel/iwlwifi/mvm/d3.c
drivers/net/wireless/intel/iwlwifi/mvm/mac-ctxt.c
drivers/net/wireless/intel/iwlwifi/mvm/rx.c
drivers/net/wireless/intel/iwlwifi/mvm/rxmq.c
drivers/net/wireless/intel/iwlwifi/pcie/tx.c
drivers/net/wireless/intersil/hostap/hostap_80211_tx.c
drivers/net/wireless/intersil/hostap/hostap_ap.c
drivers/net/wireless/intersil/hostap/hostap_hw.c
drivers/net/wireless/intersil/hostap/hostap_main.c
drivers/net/wireless/intersil/orinoco/main.c
drivers/net/wireless/intersil/p54/p54spi.c
drivers/net/wireless/intersil/p54/txrx.c
drivers/net/wireless/mac80211_hwsim.c
drivers/net/wireless/marvell/libertas/if_sdio.c
drivers/net/wireless/marvell/mwifiex/11n_aggr.c
drivers/net/wireless/marvell/mwifiex/cfg80211.c
drivers/net/wireless/marvell/mwifiex/tdls.c
drivers/net/wireless/mediatek/mt7601u/dma.c
drivers/net/wireless/mediatek/mt7601u/mcu.c
drivers/net/wireless/quantenna/qtnfmac/pearl/pcie.c
drivers/net/wireless/quantenna/qtnfmac/qlink_util.h
drivers/net/wireless/ralink/rt2x00/rt2x00debug.c
drivers/net/wireless/realtek/rtlwifi/pci.c
drivers/net/wireless/realtek/rtlwifi/rtl8188ee/fw.c
drivers/net/wireless/realtek/rtlwifi/rtl8192se/fw.c
drivers/net/wireless/realtek/rtlwifi/usb.c
drivers/net/wireless/rsi/rsi_91x_mgmt.c
drivers/net/wireless/st/cw1200/scan.c
drivers/net/wireless/ti/wl1251/main.c
drivers/net/wireless/ti/wlcore/cmd.c
drivers/net/wireless/ti/wlcore/rx.c
drivers/net/wireless/zydas/zd1201.c
drivers/net/wireless/zydas/zd1211rw/zd_mac.c
drivers/nfc/fdp/fdp.c
drivers/nfc/fdp/i2c.c
drivers/nfc/nfcmrvl/fw_dnld.c
drivers/nfc/nfcmrvl/i2c.c
drivers/nfc/nfcmrvl/usb.c
drivers/nfc/nxp-nci/firmware.c
drivers/nfc/nxp-nci/i2c.c
drivers/nfc/pn533/pn533.c
drivers/nfc/pn533/usb.c
drivers/nfc/port100.c
drivers/nfc/s3fwrn5/firmware.c
drivers/nfc/s3fwrn5/i2c.c
drivers/nfc/st21nfca/dep.c
drivers/nfc/st21nfca/i2c.c
drivers/rpmsg/rpmsg_char.c
drivers/s390/net/ctcm_fsms.c
drivers/s390/net/ctcm_main.c
drivers/s390/net/ctcm_mpc.c
drivers/s390/net/lcs.c
drivers/s390/net/netiucv.c
drivers/s390/net/qeth_core_main.c
drivers/staging/gdm724x/gdm_lte.c
drivers/staging/ks7010/ks_hostif.c
drivers/staging/most/aim-network/networking.c
drivers/staging/octeon/ethernet-rx.c
drivers/staging/rtl8188eu/core/rtw_recv.c
drivers/staging/rtl8188eu/os_dep/mon.c
drivers/staging/rtl8192e/rtllib_rx.c
drivers/staging/rtl8192e/rtllib_softmac.c
drivers/staging/rtl8192e/rtllib_tx.c
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c
drivers/staging/rtl8192u/r819xU_cmdpkt.c
drivers/staging/rtl8712/rtl8712_recv.c
drivers/staging/rtl8723bs/os_dep/recv_linux.c
drivers/staging/wilc1000/linux_mon.c
drivers/staging/wilc1000/linux_wlan.c
drivers/staging/wlan-ng/hfa384x_usb.c
drivers/tty/ipwireless/network.c
drivers/tty/n_gsm.c
drivers/tty/synclink.c
drivers/tty/synclink_gt.c
drivers/tty/synclinkmp.c
drivers/usb/gadget/function/f_ncm.c
drivers/usb/gadget/function/f_phonet.c
include/linux/mISDNif.h
include/linux/skbuff.h
lib/nlattr.c
net/batman-adv/bat_iv_ogm.c
net/batman-adv/bat_v_ogm.c
net/batman-adv/fragmentation.c
net/bluetooth/cmtp/core.c
net/bluetooth/hci_core.c
net/bluetooth/hci_request.c
net/bluetooth/hci_sock.c
net/bluetooth/hidp/core.c
net/bluetooth/l2cap_core.c
net/bluetooth/mgmt_util.c
net/bluetooth/rfcomm/tty.c
net/bridge/netfilter/nft_reject_bridge.c
net/can/bcm.c
net/decnet/dn_nsp_out.c
net/ieee802154/6lowpan/tx.c
net/ipv6/mcast.c
net/irda/ircomm/ircomm_tty.c
net/irda/irlap_frame.c
net/key/af_key.c
net/mac80211/ibss.c
net/mac80211/mesh.c
net/mac80211/mlme.c
net/mac80211/offchannel.c
net/mac80211/rx.c
net/mac80211/tdls.c
net/mac80211/tx.c
net/mac80211/util.c
net/netlink/af_netlink.c
net/nfc/digital_dep.c
net/nfc/hci/core.c
net/nfc/llcp_commands.c
net/nfc/llcp_core.c
net/nfc/nci/core.c
net/nfc/nci/data.c
net/nfc/nci/hci.c
net/nfc/nci/uart.c
net/qrtr/qrtr.c
net/sctp/output.c
net/sctp/sm_make_chunk.c
net/vmw_vsock/virtio_transport_common.c
net/x25/x25_subr.c