summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorGustavo A. R. Silva <gustavoars@kernel.org>2024-10-29 15:58:47 -0600
committerJakub Kicinski <kuba@kernel.org>2024-11-03 11:06:58 -0800
commit3bd9b9abdf1563a22041b7255baea6d449902f1a (patch)
treeb8159f0c65ac80d8890488fdb0f5d17a3126b25f /net
parent43d3487035e9a86fad952de4240a518614240d43 (diff)
net: ethtool: Avoid thousands of -Wflex-array-member-not-at-end warnings
-Wflex-array-member-not-at-end was introduced in GCC-14, and we are getting ready to enable it, globally. Change the type of the middle struct member currently causing trouble from `struct ethtool_link_settings` to `struct ethtool_link_settings_hdr`. Additionally, update the type of some variables in various functions that don't access the flexible-array member, changing them to the newly created `struct ethtool_link_settings_hdr`. These changes are needed because the type of the conflicting middle members changed. So, those instances that expect the type to be `struct ethtool_link_settings` should be adjusted to the newly created type `struct ethtool_link_settings_hdr`. Also, adjust variable declarations to follow the reverse xmas tree convention. Fix 3338 of the following -Wflex-array-member-not-at-end warnings: include/linux/ethtool.h:214:38: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Link: https://patch.msgid.link/0bc2809fe2a6c11dd4c8a9a10d9bd65cccdb559b.1730238285.git.gustavoars@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net')
-rw-r--r--net/ethtool/ioctl.c2
-rw-r--r--net/ethtool/linkinfo.c8
-rw-r--r--net/ethtool/linkmodes.c18
3 files changed, 16 insertions, 12 deletions
diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
index 5cc131cdb1bc..7da94e26ced6 100644
--- a/net/ethtool/ioctl.c
+++ b/net/ethtool/ioctl.c
@@ -425,7 +425,7 @@ convert_link_ksettings_to_legacy_settings(
/* layout of the struct passed from/to userland */
struct ethtool_link_usettings {
- struct ethtool_link_settings base;
+ struct ethtool_link_settings_hdr base;
struct {
__u32 supported[__ETHTOOL_LINK_MODE_MASK_NU32];
__u32 advertising[__ETHTOOL_LINK_MODE_MASK_NU32];
diff --git a/net/ethtool/linkinfo.c b/net/ethtool/linkinfo.c
index 30b8ce275159..2d5bc57160be 100644
--- a/net/ethtool/linkinfo.c
+++ b/net/ethtool/linkinfo.c
@@ -8,9 +8,9 @@ struct linkinfo_req_info {
};
struct linkinfo_reply_data {
- struct ethnl_reply_data base;
- struct ethtool_link_ksettings ksettings;
- struct ethtool_link_settings *lsettings;
+ struct ethnl_reply_data base;
+ struct ethtool_link_ksettings ksettings;
+ struct ethtool_link_settings_hdr *lsettings;
};
#define LINKINFO_REPDATA(__reply_base) \
@@ -98,7 +98,7 @@ static int
ethnl_set_linkinfo(struct ethnl_req_info *req_info, struct genl_info *info)
{
struct ethtool_link_ksettings ksettings = {};
- struct ethtool_link_settings *lsettings;
+ struct ethtool_link_settings_hdr *lsettings;
struct net_device *dev = req_info->dev;
struct nlattr **tb = info->attrs;
bool mod = false;
diff --git a/net/ethtool/linkmodes.c b/net/ethtool/linkmodes.c
index 259cd9ef1f2a..17e49cf89f03 100644
--- a/net/ethtool/linkmodes.c
+++ b/net/ethtool/linkmodes.c
@@ -11,10 +11,10 @@ struct linkmodes_req_info {
};
struct linkmodes_reply_data {
- struct ethnl_reply_data base;
- struct ethtool_link_ksettings ksettings;
- struct ethtool_link_settings *lsettings;
- bool peer_empty;
+ struct ethnl_reply_data base;
+ struct ethtool_link_ksettings ksettings;
+ struct ethtool_link_settings_hdr *lsettings;
+ bool peer_empty;
};
#define LINKMODES_REPDATA(__reply_base) \
@@ -62,10 +62,12 @@ static int linkmodes_reply_size(const struct ethnl_req_info *req_base,
{
const struct linkmodes_reply_data *data = LINKMODES_REPDATA(reply_base);
const struct ethtool_link_ksettings *ksettings = &data->ksettings;
- const struct ethtool_link_settings *lsettings = &ksettings->base;
bool compact = req_base->flags & ETHTOOL_FLAG_COMPACT_BITSETS;
+ const struct ethtool_link_settings_hdr *lsettings;
int len, ret;
+ lsettings = &ksettings->base;
+
len = nla_total_size(sizeof(u8)) /* LINKMODES_AUTONEG */
+ nla_total_size(sizeof(u32)) /* LINKMODES_SPEED */
+ nla_total_size(sizeof(u32)) /* LINKMODES_LANES */
@@ -103,10 +105,12 @@ static int linkmodes_fill_reply(struct sk_buff *skb,
{
const struct linkmodes_reply_data *data = LINKMODES_REPDATA(reply_base);
const struct ethtool_link_ksettings *ksettings = &data->ksettings;
- const struct ethtool_link_settings *lsettings = &ksettings->base;
bool compact = req_base->flags & ETHTOOL_FLAG_COMPACT_BITSETS;
+ const struct ethtool_link_settings_hdr *lsettings;
int ret;
+ lsettings = &ksettings->base;
+
if (nla_put_u8(skb, ETHTOOL_A_LINKMODES_AUTONEG, lsettings->autoneg))
return -EMSGSIZE;
@@ -237,7 +241,7 @@ static int ethnl_update_linkmodes(struct genl_info *info, struct nlattr **tb,
struct ethtool_link_ksettings *ksettings,
bool *mod, const struct net_device *dev)
{
- struct ethtool_link_settings *lsettings = &ksettings->base;
+ struct ethtool_link_settings_hdr *lsettings = &ksettings->base;
bool req_speed, req_lanes, req_duplex;
const struct nlattr *master_slave_cfg, *lanes_cfg;
int ret;