Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'uapi-net-ethtool-avoid-thousands-of-wflex-array-member-not-at-end-warnings'

Gustavo A. R. Silva says:

====================
UAPI: net/ethtool: Avoid thousands of -Wflex-array-member-not-at-end warnings

Small patch series aimed at fixing thousands of -Wflex-array-member-not-at-end
warnings by creating a new tagged struct within a flexible structure. We then
use this new struct type to fix problematic middle-flex-array declarations in
multiple composite structs, as well as to update the type of some variables in
various functions.

v1: https://lore.kernel.org/cover.1729536776.git.gustavoars@kernel.org
====================

Link: https://patch.msgid.link/cover.1730238285.git.gustavoars@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+44 -37
+3 -3
drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
··· 2781 2781 static void bnxt_get_default_speeds(struct ethtool_link_ksettings *lk_ksettings, 2782 2782 struct bnxt_link_info *link_info) 2783 2783 { 2784 - struct ethtool_link_settings *base = &lk_ksettings->base; 2784 + struct ethtool_link_settings_hdr *base = &lk_ksettings->base; 2785 2785 2786 2786 if (link_info->link_state == BNXT_LINK_STATE_UP) { 2787 2787 base->speed = bnxt_fw_to_ethtool_speed(link_info->link_speed); ··· 2800 2800 static int bnxt_get_link_ksettings(struct net_device *dev, 2801 2801 struct ethtool_link_ksettings *lk_ksettings) 2802 2802 { 2803 - struct ethtool_link_settings *base = &lk_ksettings->base; 2803 + struct ethtool_link_settings_hdr *base = &lk_ksettings->base; 2804 2804 enum ethtool_link_mode_bit_indices link_mode; 2805 2805 struct bnxt *bp = netdev_priv(dev); 2806 2806 struct bnxt_link_info *link_info; ··· 3023 3023 static int bnxt_set_link_ksettings(struct net_device *dev, 3024 3024 const struct ethtool_link_ksettings *lk_ksettings) 3025 3025 { 3026 + const struct ethtool_link_settings_hdr *base = &lk_ksettings->base; 3026 3027 struct bnxt *bp = netdev_priv(dev); 3027 3028 struct bnxt_link_info *link_info = &bp->link_info; 3028 - const struct ethtool_link_settings *base = &lk_ksettings->base; 3029 3029 bool set_pause = false; 3030 3030 u32 speed, lanes = 0; 3031 3031 int rc = 0;
+2 -2
drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c
··· 662 662 static int get_link_ksettings(struct net_device *dev, 663 663 struct ethtool_link_ksettings *link_ksettings) 664 664 { 665 + struct ethtool_link_settings_hdr *base = &link_ksettings->base; 665 666 struct port_info *pi = netdev_priv(dev); 666 - struct ethtool_link_settings *base = &link_ksettings->base; 667 667 668 668 /* For the nonce, the Firmware doesn't send up Port State changes 669 669 * when the Virtual Interface attached to the Port is down. So ··· 717 717 static int set_link_ksettings(struct net_device *dev, 718 718 const struct ethtool_link_ksettings *link_ksettings) 719 719 { 720 + const struct ethtool_link_settings_hdr *base = &link_ksettings->base; 720 721 struct port_info *pi = netdev_priv(dev); 721 722 struct link_config *lc = &pi->link_cfg; 722 - const struct ethtool_link_settings *base = &link_ksettings->base; 723 723 struct link_config old_lc; 724 724 unsigned int fw_caps; 725 725 int ret = 0;
+1 -1
drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
··· 1436 1436 static int cxgb4vf_get_link_ksettings(struct net_device *dev, 1437 1437 struct ethtool_link_ksettings *link_ksettings) 1438 1438 { 1439 + struct ethtool_link_settings_hdr *base = &link_ksettings->base; 1439 1440 struct port_info *pi = netdev_priv(dev); 1440 - struct ethtool_link_settings *base = &link_ksettings->base; 1441 1441 1442 1442 /* For the nonce, the Firmware doesn't send up Port State changes 1443 1443 * when the Virtual Interface attached to the Port is down. So
+1 -1
drivers/net/ethernet/cisco/enic/enic_ethtool.c
··· 129 129 static int enic_get_ksettings(struct net_device *netdev, 130 130 struct ethtool_link_ksettings *ecmd) 131 131 { 132 + struct ethtool_link_settings_hdr *base = &ecmd->base; 132 133 struct enic *enic = netdev_priv(netdev); 133 - struct ethtool_link_settings *base = &ecmd->base; 134 134 135 135 ethtool_link_ksettings_add_link_mode(ecmd, supported, 136 136 10000baseT_Full);
+2 -2
drivers/net/ethernet/qlogic/qede/qede_ethtool.c
··· 504 504 struct ethtool_link_ksettings *cmd) 505 505 { 506 506 typeof(cmd->link_modes) *link_modes = &cmd->link_modes; 507 - struct ethtool_link_settings *base = &cmd->base; 507 + struct ethtool_link_settings_hdr *base = &cmd->base; 508 508 struct qede_dev *edev = netdev_priv(dev); 509 509 struct qed_link_output current_link; 510 510 ··· 537 537 static int qede_set_link_ksettings(struct net_device *dev, 538 538 const struct ethtool_link_ksettings *cmd) 539 539 { 540 - const struct ethtool_link_settings *base = &cmd->base; 540 + const struct ethtool_link_settings_hdr *base = &cmd->base; 541 541 const struct ethtool_forced_speed_map *map; 542 542 struct qede_dev *edev = netdev_priv(dev); 543 543 struct qed_link_output current_link;
+1 -1
include/linux/ethtool.h
··· 211 211 * fields, but they are allowed to overwrite them (will be ignored). 212 212 */ 213 213 struct ethtool_link_ksettings { 214 - struct ethtool_link_settings base; 214 + struct ethtool_link_settings_hdr base; 215 215 struct { 216 216 __ETHTOOL_DECLARE_LINK_MODE_MASK(supported); 217 217 __ETHTOOL_DECLARE_LINK_MODE_MASK(advertising);
+18 -15
include/uapi/linux/ethtool.h
··· 2511 2511 * autonegotiation; 0 if unknown or not applicable. Read-only. 2512 2512 */ 2513 2513 struct ethtool_link_settings { 2514 - __u32 cmd; 2515 - __u32 speed; 2516 - __u8 duplex; 2517 - __u8 port; 2518 - __u8 phy_address; 2519 - __u8 autoneg; 2520 - __u8 mdio_support; 2521 - __u8 eth_tp_mdix; 2522 - __u8 eth_tp_mdix_ctrl; 2523 - __s8 link_mode_masks_nwords; 2524 - __u8 transceiver; 2525 - __u8 master_slave_cfg; 2526 - __u8 master_slave_state; 2527 - __u8 rate_matching; 2528 - __u32 reserved[7]; 2514 + /* New members MUST be added within the __struct_group() macro below. */ 2515 + __struct_group(ethtool_link_settings_hdr, hdr, /* no attrs */, 2516 + __u32 cmd; 2517 + __u32 speed; 2518 + __u8 duplex; 2519 + __u8 port; 2520 + __u8 phy_address; 2521 + __u8 autoneg; 2522 + __u8 mdio_support; 2523 + __u8 eth_tp_mdix; 2524 + __u8 eth_tp_mdix_ctrl; 2525 + __s8 link_mode_masks_nwords; 2526 + __u8 transceiver; 2527 + __u8 master_slave_cfg; 2528 + __u8 master_slave_state; 2529 + __u8 rate_matching; 2530 + __u32 reserved[7]; 2531 + ); 2529 2532 __u32 link_mode_masks[]; 2530 2533 /* layout of link_mode_masks fields: 2531 2534 * __u32 map_supported[link_mode_masks_nwords];
+1 -1
net/ethtool/ioctl.c
··· 425 425 426 426 /* layout of the struct passed from/to userland */ 427 427 struct ethtool_link_usettings { 428 - struct ethtool_link_settings base; 428 + struct ethtool_link_settings_hdr base; 429 429 struct { 430 430 __u32 supported[__ETHTOOL_LINK_MODE_MASK_NU32]; 431 431 __u32 advertising[__ETHTOOL_LINK_MODE_MASK_NU32];
+4 -4
net/ethtool/linkinfo.c
··· 8 8 }; 9 9 10 10 struct linkinfo_reply_data { 11 - struct ethnl_reply_data base; 12 - struct ethtool_link_ksettings ksettings; 13 - struct ethtool_link_settings *lsettings; 11 + struct ethnl_reply_data base; 12 + struct ethtool_link_ksettings ksettings; 13 + struct ethtool_link_settings_hdr *lsettings; 14 14 }; 15 15 16 16 #define LINKINFO_REPDATA(__reply_base) \ ··· 98 98 ethnl_set_linkinfo(struct ethnl_req_info *req_info, struct genl_info *info) 99 99 { 100 100 struct ethtool_link_ksettings ksettings = {}; 101 - struct ethtool_link_settings *lsettings; 101 + struct ethtool_link_settings_hdr *lsettings; 102 102 struct net_device *dev = req_info->dev; 103 103 struct nlattr **tb = info->attrs; 104 104 bool mod = false;
+11 -7
net/ethtool/linkmodes.c
··· 11 11 }; 12 12 13 13 struct linkmodes_reply_data { 14 - struct ethnl_reply_data base; 15 - struct ethtool_link_ksettings ksettings; 16 - struct ethtool_link_settings *lsettings; 17 - bool peer_empty; 14 + struct ethnl_reply_data base; 15 + struct ethtool_link_ksettings ksettings; 16 + struct ethtool_link_settings_hdr *lsettings; 17 + bool peer_empty; 18 18 }; 19 19 20 20 #define LINKMODES_REPDATA(__reply_base) \ ··· 62 62 { 63 63 const struct linkmodes_reply_data *data = LINKMODES_REPDATA(reply_base); 64 64 const struct ethtool_link_ksettings *ksettings = &data->ksettings; 65 - const struct ethtool_link_settings *lsettings = &ksettings->base; 66 65 bool compact = req_base->flags & ETHTOOL_FLAG_COMPACT_BITSETS; 66 + const struct ethtool_link_settings_hdr *lsettings; 67 67 int len, ret; 68 + 69 + lsettings = &ksettings->base; 68 70 69 71 len = nla_total_size(sizeof(u8)) /* LINKMODES_AUTONEG */ 70 72 + nla_total_size(sizeof(u32)) /* LINKMODES_SPEED */ ··· 105 103 { 106 104 const struct linkmodes_reply_data *data = LINKMODES_REPDATA(reply_base); 107 105 const struct ethtool_link_ksettings *ksettings = &data->ksettings; 108 - const struct ethtool_link_settings *lsettings = &ksettings->base; 109 106 bool compact = req_base->flags & ETHTOOL_FLAG_COMPACT_BITSETS; 107 + const struct ethtool_link_settings_hdr *lsettings; 110 108 int ret; 109 + 110 + lsettings = &ksettings->base; 111 111 112 112 if (nla_put_u8(skb, ETHTOOL_A_LINKMODES_AUTONEG, lsettings->autoneg)) 113 113 return -EMSGSIZE; ··· 241 237 struct ethtool_link_ksettings *ksettings, 242 238 bool *mod, const struct net_device *dev) 243 239 { 244 - struct ethtool_link_settings *lsettings = &ksettings->base; 240 + struct ethtool_link_settings_hdr *lsettings = &ksettings->base; 245 241 bool req_speed, req_lanes, req_duplex; 246 242 const struct nlattr *master_slave_cfg, *lanes_cfg; 247 243 int ret;