diff options
author | Michal Kubecek <mkubecek@suse.cz> | 2020-08-03 13:57:24 +0200 |
---|---|---|
committer | Michal Kubecek <mkubecek@suse.cz> | 2020-08-04 14:15:28 +0200 |
commit | ecfd3b84d3df26e550440de70e1cea3010e85af4 (patch) | |
tree | bffb5e12724c13c7ee8164dcbf9c4dd2e55799f6 | |
parent | 0b49ed378aa5ad23b8e6a102570cd8904d1f0b07 (diff) | |
download | ethtool-ecfd3b84d3df26e550440de70e1cea3010e85af4.tar.gz |
ioctl: avoid zero length array warning in get_stringset()
Starting with gcc10, gcc issues a warning about accessing elements of
zero leghth arrays. This is usually fixed by using C99 variable length
arrays but struct ethtool_sset_info is part of kernel UAPI so use an
auxiliary pointer instead.
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
-rw-r--r-- | ethtool.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -1632,7 +1632,9 @@ get_stringset(struct cmd_context *ctx, enum ethtool_stringset set_id, sset_info.hdr.reserved = 0; sset_info.hdr.sset_mask = 1ULL << set_id; if (send_ioctl(ctx, &sset_info) == 0) { - len = sset_info.hdr.sset_mask ? sset_info.hdr.data[0] : 0; + const u32 *sset_lengths = sset_info.hdr.data; + + len = sset_info.hdr.sset_mask ? sset_lengths[0] : 0; } else if (errno == EOPNOTSUPP && drvinfo_offset != 0) { /* Fallback for old kernel versions */ drvinfo.cmd = ETHTOOL_GDRVINFO; |