wifi: move from strlcpy with unused retval to strscpy
authorWolfram Sang <wsa+renesas@sang-engineering.com>
Tue, 30 Aug 2022 20:14:53 +0000 (22:14 +0200)
committerKalle Valo <kvalo@kernel.org>
Fri, 2 Sep 2022 08:47:22 +0000 (11:47 +0300)
Follow the advice of the below link and prefer 'strscpy' in this
subsystem. Conversion is 1:1 because the return value is not used.
Generated by a coccinelle script.

Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://lore.kernel.org/r/20220830201457.7984-2-wsa+renesas@sang-engineering.com
22 files changed:
drivers/net/wireless/ath/ath6kl/init.c
drivers/net/wireless/ath/carl9170/fw.c
drivers/net/wireless/ath/wil6210/main.c
drivers/net/wireless/ath/wil6210/netdev.c
drivers/net/wireless/ath/wil6210/wmi.c
drivers/net/wireless/atmel/atmel.c
drivers/net/wireless/broadcom/b43/leds.c
drivers/net/wireless/broadcom/b43legacy/leds.c
drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
drivers/net/wireless/intel/ipw2x00/ipw2100.c
drivers/net/wireless/intel/ipw2x00/ipw2200.c
drivers/net/wireless/intel/iwlegacy/3945-mac.c
drivers/net/wireless/intersil/hostap/hostap_ioctl.c
drivers/net/wireless/marvell/libertas/ethtool.c
drivers/net/wireless/microchip/wilc1000/mon.c
drivers/net/wireless/quantenna/qtnfmac/cfg80211.c
drivers/net/wireless/quantenna/qtnfmac/commands.c
drivers/net/wireless/realtek/rtl818x/rtl8187/leds.c
drivers/net/wireless/wl3501_cs.c

index 9b5c7d8..201e455 100644 (file)
@@ -1014,7 +1014,7 @@ static int ath6kl_fetch_fw_apin(struct ath6kl *ar, const char *name)
 
                switch (ie_id) {
                case ATH6KL_FW_IE_FW_VERSION:
-                       strlcpy(ar->wiphy->fw_version, data,
+                       strscpy(ar->wiphy->fw_version, data,
                                min(sizeof(ar->wiphy->fw_version), ie_len+1));
 
                        ath6kl_dbg(ATH6KL_DBG_BOOT,
index 1ab09e1..4c1aecd 100644 (file)
@@ -105,7 +105,7 @@ static void carl9170_fw_info(struct ar9170 *ar)
                         CARL9170FW_GET_MONTH(fw_date),
                         CARL9170FW_GET_DAY(fw_date));
 
-               strlcpy(ar->hw->wiphy->fw_version, motd_desc->release,
+               strscpy(ar->hw->wiphy->fw_version, motd_desc->release,
                        sizeof(ar->hw->wiphy->fw_version));
        }
 }
index 7da87c9..94e61db 100644 (file)
@@ -1305,7 +1305,7 @@ void wil_get_board_file(struct wil6210_priv *wil, char *buf, size_t len)
                        board_file = WIL_BOARD_FILE_NAME;
        }
 
-       strlcpy(buf, board_file, len);
+       strscpy(buf, board_file, len);
 }
 
 static int wil_get_bl_info(struct wil6210_priv *wil)
index 87a88f2..e76b38a 100644 (file)
@@ -445,7 +445,7 @@ int wil_if_add(struct wil6210_priv *wil)
 
        wil_dbg_misc(wil, "entered");
 
-       strlcpy(wiphy->fw_version, wil->fw_version, sizeof(wiphy->fw_version));
+       strscpy(wiphy->fw_version, wil->fw_version, sizeof(wiphy->fw_version));
 
        rc = wiphy_register(wiphy);
        if (rc < 0) {
index ea7bd40..6a5976a 100644 (file)
@@ -780,7 +780,7 @@ static void wmi_evt_ready(struct wil6210_vif *vif, int id, void *d, int len)
                return; /* FW load will fail after timeout */
        }
        /* ignore MAC address, we already have it from the boot loader */
-       strlcpy(wiphy->fw_version, wil->fw_version, sizeof(wiphy->fw_version));
+       strscpy(wiphy->fw_version, wil->fw_version, sizeof(wiphy->fw_version));
 
        if (len > offsetof(struct wmi_ready_event, rfc_read_calib_result)) {
                wil_dbg_wmi(wil, "rfc calibration result %d\n",
index 0361c8e..45d079b 100644 (file)
@@ -1518,7 +1518,7 @@ struct net_device *init_atmel_card(unsigned short irq, unsigned long port,
        priv->firmware = NULL;
        priv->firmware_type = fw_type;
        if (firmware) /* module parameter */
-               strlcpy(priv->firmware_id, firmware, sizeof(priv->firmware_id));
+               strscpy(priv->firmware_id, firmware, sizeof(priv->firmware_id));
        priv->bus_type = card_present ? BUS_TYPE_PCCARD : BUS_TYPE_PCI;
        priv->station_state = STATION_STATE_DOWN;
        priv->do_rx_crc = 0;
index 982a772..bfe1be3 100644 (file)
@@ -118,7 +118,7 @@ static int b43_register_led(struct b43_wldev *dev, struct b43_led *led,
        led->wl = dev->wl;
        led->index = led_index;
        led->activelow = activelow;
-       strlcpy(led->name, name, sizeof(led->name));
+       strscpy(led->name, name, sizeof(led->name));
        atomic_set(&led->state, 0);
 
        led->led_dev.name = led->name;
index 38b5be3..79e6fd2 100644 (file)
@@ -88,7 +88,7 @@ static int b43legacy_register_led(struct b43legacy_wldev *dev,
        led->dev = dev;
        led->index = led_index;
        led->activelow = activelow;
-       strlcpy(led->name, name, sizeof(led->name));
+       strscpy(led->name, name, sizeof(led->name));
 
        led->led_dev.name = led->name;
        led->led_dev.default_trigger = default_trigger;
index 7485e78..372deeb 100644 (file)
@@ -261,7 +261,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
                                     &revinfo, sizeof(revinfo));
        if (err < 0) {
                bphy_err(drvr, "retrieving revision info failed, %d\n", err);
-               strlcpy(ri->chipname, "UNKNOWN", sizeof(ri->chipname));
+               strscpy(ri->chipname, "UNKNOWN", sizeof(ri->chipname));
        } else {
                ri->vendorid = le32_to_cpu(revinfo.vendorid);
                ri->deviceid = le32_to_cpu(revinfo.deviceid);
@@ -314,7 +314,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
 
        /* locate firmware version number for ethtool */
        ptr = strrchr(buf, ' ') + 1;
-       strlcpy(ifp->drvr->fwver, ptr, sizeof(ifp->drvr->fwver));
+       strscpy(ifp->drvr->fwver, ptr, sizeof(ifp->drvr->fwver));
 
        /* Query for 'clmver' to get CLM version info from firmware */
        memset(buf, 0, sizeof(buf));
@@ -424,11 +424,11 @@ static void brcmf_mp_attach(void)
         * if not set then if available use the platform data version. To make
         * sure it gets initialized at all, always copy the module param version
         */
-       strlcpy(brcmf_mp_global.firmware_path, brcmf_firmware_path,
+       strscpy(brcmf_mp_global.firmware_path, brcmf_firmware_path,
                BRCMF_FW_ALTPATH_LEN);
        if ((brcmfmac_pdata) && (brcmfmac_pdata->fw_alternative_path) &&
            (brcmf_mp_global.firmware_path[0] == '\0')) {
-               strlcpy(brcmf_mp_global.firmware_path,
+               strscpy(brcmf_mp_global.firmware_path,
                        brcmfmac_pdata->fw_alternative_path,
                        BRCMF_FW_ALTPATH_LEN);
        }
index e476d7d..2627221 100644 (file)
@@ -561,10 +561,10 @@ static void brcmf_ethtool_get_drvinfo(struct net_device *ndev,
 
        if (drvr->revinfo.result == 0)
                brcmu_dotrev_str(drvr->revinfo.driverrev, drev);
-       strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver));
-       strlcpy(info->version, drev, sizeof(info->version));
-       strlcpy(info->fw_version, drvr->fwver, sizeof(info->fw_version));
-       strlcpy(info->bus_info, dev_name(drvr->bus_if->dev),
+       strscpy(info->driver, KBUILD_MODNAME, sizeof(info->driver));
+       strscpy(info->version, drev, sizeof(info->version));
+       strscpy(info->fw_version, drvr->fwver, sizeof(info->fw_version));
+       strscpy(info->bus_info, dev_name(drvr->bus_if->dev),
                sizeof(info->bus_info));
 }
 
index b8379e4..15e99d8 100644 (file)
@@ -769,7 +769,7 @@ brcmf_fw_alloc_request(u32 chip, u32 chiprev,
                fwnames[j].path[0] = '\0';
                /* check if firmware path is provided by module parameter */
                if (brcmf_mp_global.firmware_path[0] != '\0') {
-                       strlcpy(fwnames[j].path, mp_path,
+                       strscpy(fwnames[j].path, mp_path,
                                BRCMF_FW_NAME_LEN);
 
                        if (end != '/') {
index 85e3b95..36af819 100644 (file)
@@ -688,7 +688,7 @@ static void brcmf_fws_macdesc_set_name(struct brcmf_fws_info *fws,
                                       struct brcmf_fws_mac_descriptor *desc)
 {
        if (desc == &fws->desc.other)
-               strlcpy(desc->name, "MAC-OTHER", sizeof(desc->name));
+               strscpy(desc->name, "MAC-OTHER", sizeof(desc->name));
        else if (desc->mac_handle)
                scnprintf(desc->name, sizeof(desc->name), "MAC-%d:%d",
                          desc->mac_handle, desc->interface_id);
index 5234511..ac36c89 100644 (file)
@@ -5907,8 +5907,8 @@ static void ipw_ethtool_get_drvinfo(struct net_device *dev,
        struct ipw2100_priv *priv = libipw_priv(dev);
        char fw_ver[64], ucode_ver[64];
 
-       strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
-       strlcpy(info->version, DRV_VERSION, sizeof(info->version));
+       strscpy(info->driver, DRV_NAME, sizeof(info->driver));
+       strscpy(info->version, DRV_VERSION, sizeof(info->version));
 
        ipw2100_get_fwversion(priv, fw_ver, sizeof(fw_ver));
        ipw2100_get_ucodeversion(priv, ucode_ver, sizeof(ucode_ver));
@@ -5916,7 +5916,7 @@ static void ipw_ethtool_get_drvinfo(struct net_device *dev,
        snprintf(info->fw_version, sizeof(info->fw_version), "%s:%d:%s",
                 fw_ver, priv->eeprom_version, ucode_ver);
 
-       strlcpy(info->bus_info, pci_name(priv->pci_dev),
+       strscpy(info->bus_info, pci_name(priv->pci_dev),
                sizeof(info->bus_info));
 }
 
index 029dace..5b483de 100644 (file)
@@ -10424,8 +10424,8 @@ static void ipw_ethtool_get_drvinfo(struct net_device *dev,
        char date[32];
        u32 len;
 
-       strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
-       strlcpy(info->version, DRV_VERSION, sizeof(info->version));
+       strscpy(info->driver, DRV_NAME, sizeof(info->driver));
+       strscpy(info->version, DRV_VERSION, sizeof(info->version));
 
        len = sizeof(vers);
        ipw_get_ordinal(p, IPW_ORD_STAT_FW_VERSION, vers, &len);
@@ -10434,7 +10434,7 @@ static void ipw_ethtool_get_drvinfo(struct net_device *dev,
 
        snprintf(info->fw_version, sizeof(info->fw_version), "%s (%s)",
                 vers, date);
-       strlcpy(info->bus_info, pci_name(p->pci_dev),
+       strscpy(info->bus_info, pci_name(p->pci_dev),
                sizeof(info->bus_info));
 }
 
index 846138d..7352d5b 100644 (file)
@@ -3254,7 +3254,7 @@ il3945_store_measurement(struct device *d, struct device_attribute *attr,
 
        if (count) {
                char *p = buffer;
-               strlcpy(buffer, buf, sizeof(buffer));
+               strscpy(buffer, buf, sizeof(buffer));
                channel = simple_strtoul(p, NULL, 0);
                if (channel)
                        params.channel = channel;
index 0a376f1..4e0a0c8 100644 (file)
@@ -3848,7 +3848,7 @@ static void prism2_get_drvinfo(struct net_device *dev,
        iface = netdev_priv(dev);
        local = iface->local;
 
-       strlcpy(info->driver, "hostap", sizeof(info->driver));
+       strscpy(info->driver, "hostap", sizeof(info->driver));
        snprintf(info->fw_version, sizeof(info->fw_version),
                 "%d.%d.%d", (local->sta_fw_ver >> 16) & 0xff,
                 (local->sta_fw_ver >> 8) & 0xff,
index d8e4f29..9f53308 100644 (file)
@@ -20,8 +20,8 @@ static void lbs_ethtool_get_drvinfo(struct net_device *dev,
                priv->fwrelease >> 16 & 0xff,
                priv->fwrelease >>  8 & 0xff,
                priv->fwrelease       & 0xff);
-       strlcpy(info->driver, "libertas", sizeof(info->driver));
-       strlcpy(info->version, lbs_driver_version, sizeof(info->version));
+       strscpy(info->driver, "libertas", sizeof(info->driver));
+       strscpy(info->version, lbs_driver_version, sizeof(info->version));
 }
 
 /*
index b5a1b65..03b7229 100644 (file)
@@ -229,7 +229,7 @@ struct net_device *wilc_wfi_init_mon_interface(struct wilc *wl,
                return NULL;
 
        wl->monitor_dev->type = ARPHRD_IEEE80211_RADIOTAP;
-       strlcpy(wl->monitor_dev->name, name, IFNAMSIZ);
+       strscpy(wl->monitor_dev->name, name, IFNAMSIZ);
        wl->monitor_dev->netdev_ops = &wilc_wfi_netdev_ops;
        wl->monitor_dev->needs_free_netdev = true;
 
index 4d796f5..bfdf03b 100644 (file)
@@ -1223,7 +1223,7 @@ int qtnf_wiphy_register(struct qtnf_hw_info *hw_info, struct qtnf_wmac *mac)
                        mac->macinfo.extended_capabilities_len;
        }
 
-       strlcpy(wiphy->fw_version, hw_info->fw_version,
+       strscpy(wiphy->fw_version, hw_info->fw_version,
                sizeof(wiphy->fw_version));
        wiphy->hw_version = hw_info->hw_version;
 
index 0fad536..b1b7347 100644 (file)
@@ -967,7 +967,7 @@ qtnf_cmd_resp_proc_hw_info(struct qtnf_bus *bus,
                hwinfo->total_rx_chain, hwinfo->total_tx_chain,
                hwinfo->fw_ver);
 
-       strlcpy(hwinfo->fw_version, bld_label, sizeof(hwinfo->fw_version));
+       strscpy(hwinfo->fw_version, bld_label, sizeof(hwinfo->fw_version));
        hwinfo->hw_version = hw_ver;
 
        return 0;
index 49421d1..f7d95c9 100644 (file)
@@ -143,7 +143,7 @@ static int rtl8187_register_led(struct ieee80211_hw *dev,
        led->dev = dev;
        led->ledpin = ledpin;
        led->is_radio = is_radio;
-       strlcpy(led->name, name, sizeof(led->name));
+       strscpy(led->name, name, sizeof(led->name));
 
        led->led_dev.name = led->name;
        led->led_dev.default_trigger = default_trigger;
index dad38fc..1b532e0 100644 (file)
@@ -1441,7 +1441,7 @@ static void wl3501_detach(struct pcmcia_device *link)
 static int wl3501_get_name(struct net_device *dev, struct iw_request_info *info,
                           union iwreq_data *wrqu, char *extra)
 {
-       strlcpy(wrqu->name, "IEEE 802.11-DS", sizeof(wrqu->name));
+       strscpy(wrqu->name, "IEEE 802.11-DS", sizeof(wrqu->name));
        return 0;
 }
 
@@ -1652,7 +1652,7 @@ static int wl3501_set_nick(struct net_device *dev, struct iw_request_info *info,
 
        if (wrqu->data.length > sizeof(this->nick))
                return -E2BIG;
-       strlcpy(this->nick, extra, wrqu->data.length);
+       strscpy(this->nick, extra, wrqu->data.length);
        return 0;
 }
 
@@ -1661,7 +1661,7 @@ static int wl3501_get_nick(struct net_device *dev, struct iw_request_info *info,
 {
        struct wl3501_card *this = netdev_priv(dev);
 
-       strlcpy(extra, this->nick, 32);
+       strscpy(extra, this->nick, 32);
        wrqu->data.length = strlen(extra);
        return 0;
 }
@@ -1965,7 +1965,7 @@ static int wl3501_config(struct pcmcia_device *link)
        this->firmware_date[0]  = '\0';
        this->rssi              = 255;
        this->chan              = iw_default_channel(this->reg_domain);
-       strlcpy(this->nick, "Planet WL3501", sizeof(this->nick));
+       strscpy(this->nick, "Planet WL3501", sizeof(this->nick));
        spin_lock_init(&this->lock);
        init_waitqueue_head(&this->wait);
        netif_start_queue(dev);