mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-27 18:40:33 +01:00
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.
(cherry picked from commit 16e1e44c5e)
(cherry picked from commit 286bb2f029)
(cherry picked from commit b474ed0044)
This commit is contained in:
parent
9a02fd2ada
commit
2ebb933596
1 changed files with 4 additions and 1 deletions
|
|
@ -197,6 +197,7 @@ ethtool_get_stringset (SocketHandle *shandle, int stringset_id)
|
|||
struct ethtool_sset_info info;
|
||||
guint32 sentinel;
|
||||
} sset_info = { };
|
||||
const guint32 *pdata;
|
||||
gs_free struct ethtool_gstrings *gstrings = NULL;
|
||||
guint32 i, len;
|
||||
|
||||
|
|
@ -209,7 +210,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 = g_malloc0 (sizeof (*gstrings) + (len * ETH_GSTRING_LEN));
|
||||
gstrings->cmd = ETHTOOL_GSTRINGS;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue