mirror of
https://github.com/torvalds/linux.git
synced 2026-06-04 20:46:48 +02:00
Merge branch 'intel-wired-lan-driver-updates-2023-10-17'
Jacob Keller says: ==================== Intel Wired LAN Driver Updates 2023-10-17 This series contains cleanups for all the Intel drivers relating to their use of format specifiers and the use of strncpy. Jesse fixes various -Wformat warnings across all the Intel networking, including various cases where a "%s" string format specifier is preferred, and using kasprintf instead of snprintf. Justin replaces all of the uses of the now deprecated strncpy with a more modern string function, primarily strscpy. ==================== Link: https://lore.kernel.org/r/20231017190411.2199743-1-jacob.e.keller@intel.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
commit
0916c65aba
|
|
@ -2841,7 +2841,7 @@ static int e100_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
|||
netdev->netdev_ops = &e100_netdev_ops;
|
||||
netdev->ethtool_ops = &e100_ethtool_ops;
|
||||
netdev->watchdog_timeo = E100_WATCHDOG_PERIOD;
|
||||
strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);
|
||||
strscpy(netdev->name, pci_name(pdev), sizeof(netdev->name));
|
||||
|
||||
nic = netdev_priv(netdev);
|
||||
netif_napi_add_weight(netdev, &nic->napi, e100_poll, E100_NAPI_WEIGHT);
|
||||
|
|
|
|||
|
|
@ -1014,7 +1014,7 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
|||
netdev->watchdog_timeo = 5 * HZ;
|
||||
netif_napi_add(netdev, &adapter->napi, e1000_clean);
|
||||
|
||||
strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);
|
||||
strscpy(netdev->name, pci_name(pdev), sizeof(netdev->name));
|
||||
|
||||
adapter->bd_number = cards_found;
|
||||
|
||||
|
|
|
|||
|
|
@ -448,10 +448,10 @@ static void fm10k_get_drvinfo(struct net_device *dev,
|
|||
{
|
||||
struct fm10k_intfc *interface = netdev_priv(dev);
|
||||
|
||||
strncpy(info->driver, fm10k_driver_name,
|
||||
sizeof(info->driver) - 1);
|
||||
strncpy(info->bus_info, pci_name(interface->pdev),
|
||||
sizeof(info->bus_info) - 1);
|
||||
strscpy(info->driver, fm10k_driver_name,
|
||||
sizeof(info->driver));
|
||||
strscpy(info->bus_info, pci_name(interface->pdev),
|
||||
sizeof(info->bus_info));
|
||||
}
|
||||
|
||||
static void fm10k_get_pauseparam(struct net_device *dev,
|
||||
|
|
|
|||
|
|
@ -456,10 +456,9 @@ int i40e_ddp_flash(struct net_device *netdev, struct ethtool_flash *flash)
|
|||
char profile_name[sizeof(I40E_DDP_PROFILE_PATH)
|
||||
+ I40E_DDP_PROFILE_NAME_MAX];
|
||||
|
||||
profile_name[sizeof(profile_name) - 1] = 0;
|
||||
strncpy(profile_name, I40E_DDP_PROFILE_PATH,
|
||||
sizeof(profile_name) - 1);
|
||||
strncat(profile_name, flash->data, I40E_DDP_PROFILE_NAME_MAX);
|
||||
scnprintf(profile_name, sizeof(profile_name), "%s%s",
|
||||
I40E_DDP_PROFILE_PATH, flash->data);
|
||||
|
||||
/* Load DDP recipe. */
|
||||
status = request_firmware(&ddp_config, profile_name,
|
||||
&netdev->dev);
|
||||
|
|
|
|||
|
|
@ -2514,11 +2514,13 @@ static void i40e_get_priv_flag_strings(struct net_device *netdev, u8 *data)
|
|||
u8 *p = data;
|
||||
|
||||
for (i = 0; i < I40E_PRIV_FLAGS_STR_LEN; i++)
|
||||
ethtool_sprintf(&p, i40e_gstrings_priv_flags[i].flag_string);
|
||||
ethtool_sprintf(&p, "%s",
|
||||
i40e_gstrings_priv_flags[i].flag_string);
|
||||
if (pf->hw.pf_id != 0)
|
||||
return;
|
||||
for (i = 0; i < I40E_GL_PRIV_FLAGS_STR_LEN; i++)
|
||||
ethtool_sprintf(&p, i40e_gl_gstrings_priv_flags[i].flag_string);
|
||||
ethtool_sprintf(&p, "%s",
|
||||
i40e_gl_gstrings_priv_flags[i].flag_string);
|
||||
}
|
||||
|
||||
static void i40e_get_strings(struct net_device *netdev, u32 stringset,
|
||||
|
|
|
|||
|
|
@ -395,11 +395,9 @@ static void iavf_get_priv_flag_strings(struct net_device *netdev, u8 *data)
|
|||
{
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < IAVF_PRIV_FLAGS_STR_LEN; i++) {
|
||||
snprintf(data, ETH_GSTRING_LEN, "%s",
|
||||
iavf_gstrings_priv_flags[i].flag_string);
|
||||
data += ETH_GSTRING_LEN;
|
||||
}
|
||||
for (i = 0; i < IAVF_PRIV_FLAGS_STR_LEN; i++)
|
||||
ethtool_sprintf(&data, "%s",
|
||||
iavf_gstrings_priv_flags[i].flag_string);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1378,8 +1378,6 @@ void iavf_disable_vlan_insertion_v2(struct iavf_adapter *adapter, u16 tpid)
|
|||
VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2);
|
||||
}
|
||||
|
||||
#define IAVF_MAX_SPEED_STRLEN 13
|
||||
|
||||
/**
|
||||
* iavf_print_link_message - print link up or down
|
||||
* @adapter: adapter structure
|
||||
|
|
@ -1397,10 +1395,6 @@ static void iavf_print_link_message(struct iavf_adapter *adapter)
|
|||
return;
|
||||
}
|
||||
|
||||
speed = kzalloc(IAVF_MAX_SPEED_STRLEN, GFP_KERNEL);
|
||||
if (!speed)
|
||||
return;
|
||||
|
||||
if (ADV_LINK_SUPPORT(adapter)) {
|
||||
link_speed_mbps = adapter->link_speed_mbps;
|
||||
goto print_link_msg;
|
||||
|
|
@ -1438,17 +1432,17 @@ static void iavf_print_link_message(struct iavf_adapter *adapter)
|
|||
|
||||
print_link_msg:
|
||||
if (link_speed_mbps > SPEED_1000) {
|
||||
if (link_speed_mbps == SPEED_2500)
|
||||
snprintf(speed, IAVF_MAX_SPEED_STRLEN, "2.5 Gbps");
|
||||
else
|
||||
if (link_speed_mbps == SPEED_2500) {
|
||||
speed = kasprintf(GFP_KERNEL, "%s", "2.5 Gbps");
|
||||
} else {
|
||||
/* convert to Gbps inline */
|
||||
snprintf(speed, IAVF_MAX_SPEED_STRLEN, "%d %s",
|
||||
link_speed_mbps / 1000, "Gbps");
|
||||
speed = kasprintf(GFP_KERNEL, "%d Gbps",
|
||||
link_speed_mbps / 1000);
|
||||
}
|
||||
} else if (link_speed_mbps == SPEED_UNKNOWN) {
|
||||
snprintf(speed, IAVF_MAX_SPEED_STRLEN, "%s", "Unknown Mbps");
|
||||
speed = kasprintf(GFP_KERNEL, "%s", "Unknown Mbps");
|
||||
} else {
|
||||
snprintf(speed, IAVF_MAX_SPEED_STRLEN, "%d %s",
|
||||
link_speed_mbps, "Mbps");
|
||||
speed = kasprintf(GFP_KERNEL, "%d Mbps", link_speed_mbps);
|
||||
}
|
||||
|
||||
netdev_info(netdev, "NIC Link is Up Speed is %s Full Duplex\n", speed);
|
||||
|
|
|
|||
|
|
@ -1133,7 +1133,7 @@ __ice_get_strings(struct net_device *netdev, u32 stringset, u8 *data,
|
|||
switch (stringset) {
|
||||
case ETH_SS_STATS:
|
||||
for (i = 0; i < ICE_VSI_STATS_LEN; i++)
|
||||
ethtool_sprintf(&p,
|
||||
ethtool_sprintf(&p, "%s",
|
||||
ice_gstrings_vsi_stats[i].stat_string);
|
||||
|
||||
if (ice_is_port_repr_netdev(netdev))
|
||||
|
|
@ -1153,7 +1153,7 @@ __ice_get_strings(struct net_device *netdev, u32 stringset, u8 *data,
|
|||
return;
|
||||
|
||||
for (i = 0; i < ICE_PF_STATS_LEN; i++)
|
||||
ethtool_sprintf(&p,
|
||||
ethtool_sprintf(&p, "%s",
|
||||
ice_gstrings_pf_stats[i].stat_string);
|
||||
|
||||
for (i = 0; i < ICE_MAX_USER_PRIORITY; i++) {
|
||||
|
|
@ -1170,7 +1170,8 @@ __ice_get_strings(struct net_device *netdev, u32 stringset, u8 *data,
|
|||
break;
|
||||
case ETH_SS_PRIV_FLAGS:
|
||||
for (i = 0; i < ICE_PRIV_FLAG_ARRAY_SIZE; i++)
|
||||
ethtool_sprintf(&p, ice_gstrings_priv_flags[i].name);
|
||||
ethtool_sprintf(&p, "%s",
|
||||
ice_gstrings_priv_flags[i].name);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ ice_get_sma_config_e810t(struct ice_hw *hw, struct ptp_pin_desc *ptp_pins)
|
|||
|
||||
/* initialize with defaults */
|
||||
for (i = 0; i < NUM_PTP_PINS_E810T; i++) {
|
||||
snprintf(ptp_pins[i].name, sizeof(ptp_pins[i].name),
|
||||
"%s", ice_pin_desc_e810t[i].name);
|
||||
strscpy(ptp_pins[i].name, ice_pin_desc_e810t[i].name,
|
||||
sizeof(ptp_pins[i].name));
|
||||
ptp_pins[i].index = ice_pin_desc_e810t[i].index;
|
||||
ptp_pins[i].func = ice_pin_desc_e810t[i].func;
|
||||
ptp_pins[i].chan = ice_pin_desc_e810t[i].chan;
|
||||
|
|
|
|||
|
|
@ -2356,10 +2356,10 @@ static void igb_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
|
|||
break;
|
||||
case ETH_SS_STATS:
|
||||
for (i = 0; i < IGB_GLOBAL_STATS_LEN; i++)
|
||||
ethtool_sprintf(&p,
|
||||
ethtool_sprintf(&p, "%s",
|
||||
igb_gstrings_stats[i].stat_string);
|
||||
for (i = 0; i < IGB_NETDEV_STATS_LEN; i++)
|
||||
ethtool_sprintf(&p,
|
||||
ethtool_sprintf(&p, "%s",
|
||||
igb_gstrings_net_stats[i].stat_string);
|
||||
for (i = 0; i < adapter->num_tx_queues; i++) {
|
||||
ethtool_sprintf(&p, "tx_queue_%u_packets", i);
|
||||
|
|
|
|||
|
|
@ -3069,6 +3069,7 @@ void igb_set_fw_version(struct igb_adapter *adapter)
|
|||
{
|
||||
struct e1000_hw *hw = &adapter->hw;
|
||||
struct e1000_fw_version fw;
|
||||
char *lbuf;
|
||||
|
||||
igb_get_fw_version(hw, &fw);
|
||||
|
||||
|
|
@ -3076,36 +3077,34 @@ void igb_set_fw_version(struct igb_adapter *adapter)
|
|||
case e1000_i210:
|
||||
case e1000_i211:
|
||||
if (!(igb_get_flash_presence_i210(hw))) {
|
||||
snprintf(adapter->fw_version,
|
||||
sizeof(adapter->fw_version),
|
||||
"%2d.%2d-%d",
|
||||
fw.invm_major, fw.invm_minor,
|
||||
fw.invm_img_type);
|
||||
lbuf = kasprintf(GFP_KERNEL, "%2d.%2d-%d",
|
||||
fw.invm_major, fw.invm_minor,
|
||||
fw.invm_img_type);
|
||||
break;
|
||||
}
|
||||
fallthrough;
|
||||
default:
|
||||
/* if option is rom valid, display its version too */
|
||||
/* if option rom is valid, display its version too */
|
||||
if (fw.or_valid) {
|
||||
snprintf(adapter->fw_version,
|
||||
sizeof(adapter->fw_version),
|
||||
"%d.%d, 0x%08x, %d.%d.%d",
|
||||
fw.eep_major, fw.eep_minor, fw.etrack_id,
|
||||
fw.or_major, fw.or_build, fw.or_patch);
|
||||
lbuf = kasprintf(GFP_KERNEL, "%d.%d, 0x%08x, %d.%d.%d",
|
||||
fw.eep_major, fw.eep_minor,
|
||||
fw.etrack_id, fw.or_major, fw.or_build,
|
||||
fw.or_patch);
|
||||
/* no option rom */
|
||||
} else if (fw.etrack_id != 0X0000) {
|
||||
snprintf(adapter->fw_version,
|
||||
sizeof(adapter->fw_version),
|
||||
"%d.%d, 0x%08x",
|
||||
fw.eep_major, fw.eep_minor, fw.etrack_id);
|
||||
lbuf = kasprintf(GFP_KERNEL, "%d.%d, 0x%08x",
|
||||
fw.eep_major, fw.eep_minor,
|
||||
fw.etrack_id);
|
||||
} else {
|
||||
snprintf(adapter->fw_version,
|
||||
sizeof(adapter->fw_version),
|
||||
"%d.%d.%d",
|
||||
fw.eep_major, fw.eep_minor, fw.eep_build);
|
||||
lbuf = kasprintf(GFP_KERNEL, "%d.%d.%d", fw.eep_major,
|
||||
fw.eep_minor, fw.eep_build);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* the truncate happens here if it doesn't fit */
|
||||
strscpy(adapter->fw_version, lbuf, sizeof(adapter->fw_version));
|
||||
kfree(lbuf);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -3264,7 +3263,7 @@ static int igb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
|||
igb_set_ethtool_ops(netdev);
|
||||
netdev->watchdog_timeo = 5 * HZ;
|
||||
|
||||
strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);
|
||||
strscpy(netdev->name, pci_name(pdev), sizeof(netdev->name));
|
||||
|
||||
netdev->mem_start = pci_resource_start(pdev, 0);
|
||||
netdev->mem_end = pci_resource_end(pdev, 0);
|
||||
|
|
|
|||
|
|
@ -2785,7 +2785,7 @@ static int igbvf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
|||
|
||||
igbvf_set_ethtool_ops(netdev);
|
||||
netdev->watchdog_timeo = 5 * HZ;
|
||||
strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);
|
||||
strscpy(netdev->name, pci_name(pdev), sizeof(netdev->name));
|
||||
|
||||
adapter->bd_number = cards_found++;
|
||||
|
||||
|
|
|
|||
|
|
@ -773,9 +773,10 @@ static void igc_ethtool_get_strings(struct net_device *netdev, u32 stringset,
|
|||
break;
|
||||
case ETH_SS_STATS:
|
||||
for (i = 0; i < IGC_GLOBAL_STATS_LEN; i++)
|
||||
ethtool_sprintf(&p, igc_gstrings_stats[i].stat_string);
|
||||
ethtool_sprintf(&p, "%s",
|
||||
igc_gstrings_stats[i].stat_string);
|
||||
for (i = 0; i < IGC_NETDEV_STATS_LEN; i++)
|
||||
ethtool_sprintf(&p,
|
||||
ethtool_sprintf(&p, "%s",
|
||||
igc_gstrings_net_stats[i].stat_string);
|
||||
for (i = 0; i < adapter->num_tx_queues; i++) {
|
||||
ethtool_sprintf(&p, "tx_queue_%u_packets", i);
|
||||
|
|
|
|||
|
|
@ -6935,7 +6935,7 @@ static int igc_probe(struct pci_dev *pdev,
|
|||
*/
|
||||
igc_get_hw_control(adapter);
|
||||
|
||||
strncpy(netdev->name, "eth%d", IFNAMSIZ);
|
||||
strscpy(netdev->name, "eth%d", sizeof(netdev->name));
|
||||
err = register_netdev(netdev);
|
||||
if (err)
|
||||
goto err_register;
|
||||
|
|
|
|||
|
|
@ -1413,11 +1413,11 @@ static void ixgbe_get_strings(struct net_device *netdev, u32 stringset,
|
|||
switch (stringset) {
|
||||
case ETH_SS_TEST:
|
||||
for (i = 0; i < IXGBE_TEST_LEN; i++)
|
||||
ethtool_sprintf(&p, ixgbe_gstrings_test[i]);
|
||||
ethtool_sprintf(&p, "%s", ixgbe_gstrings_test[i]);
|
||||
break;
|
||||
case ETH_SS_STATS:
|
||||
for (i = 0; i < IXGBE_GLOBAL_STATS_LEN; i++)
|
||||
ethtool_sprintf(&p,
|
||||
ethtool_sprintf(&p, "%s",
|
||||
ixgbe_gstrings_stats[i].stat_string);
|
||||
for (i = 0; i < netdev->num_tx_queues; i++) {
|
||||
ethtool_sprintf(&p, "tx_queue_%u_packets", i);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user