summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-02-10 10:55:12 +0100
committerThomas Haller <thaller@redhat.com>2020-02-10 11:39:01 +0100
commit16e1e44c5ef96d28663208b005cc3343b95ba634 (patch)
tree4b99d497817c6fd233b896b52c64e1c2fc605c0d
parent0931c4f2eaa2092e622dba8f58deb91760c4b53d (diff)
downloadNetworkManager-16e1e44c5ef96d28663208b005cc3343b95ba634.tar.gz
platform: fix GCC warning about zero-length array in ethtool_get_stringset()
GCC 10 complains about accesses to elements of zero-length arrays that overlap other members of the same object: src/platform/nm-platform-utils.c: In function ‘ethtool_get_stringset’: src/platform/nm-platform-utils.c:355:27: error: array subscript 0 is outside the bounds of an interior zero-length array ‘__u32[0]’ {aka ‘unsigned int[0]’} [-Werror=zero-length-bounds] 355 | len = sset_info.info.data[0]; | ~~~~~~~~~~~~~~~~~~~^~~ In file included from src/platform/nm-platform-utils.c:12: /usr/include/linux/ethtool.h:647:8: note: while referencing ‘data’ 647 | __u32 data[0]; | ^~~~ Fix this warning.
-rw-r--r--src/platform/nm-platform-utils.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/platform/nm-platform-utils.c b/src/platform/nm-platform-utils.c
index 4f0da581d0..39bf719bae 100644
--- a/src/platform/nm-platform-utils.c
+++ b/src/platform/nm-platform-utils.c
@@ -343,6 +343,7 @@ ethtool_get_stringset (SocketHandle *shandle, int stringset_id)
.info.reserved = 0,
.info.sset_mask = (1ULL << stringset_id),
};
+ const guint32 *pdata;
gs_free struct ethtool_gstrings *gstrings = NULL;
gsize gstrings_len;
guint32 i, len;
@@ -352,7 +353,9 @@ ethtool_get_stringset (SocketHandle *shandle, int stringset_id)
if (!sset_info.info.sset_mask)
return NULL;
- len = sset_info.info.data[0];
+ pdata = (guint32 *) sset_info.info.data;
+
+ len = *pdata;
gstrings_len = sizeof (*gstrings) + (len * ETH_GSTRING_LEN);
gstrings = g_malloc0 (gstrings_len);