summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-02-10 10:51:49 +0100
committerThomas Haller <thaller@redhat.com>2020-02-10 11:26:59 +0100
commit1fd7e4513976d31509f4ad43c425f1b92e77e835 (patch)
treedf5ad393710d0d06989974bec07bcd0ae1488d81
parent5cc8ca4038454bdf5c7be205396433362d12b839 (diff)
downloadNetworkManager-1fd7e4513976d31509f4ad43c425f1b92e77e835.tar.gz
Revert "platform: fix GCC warning about zero-lenght array (1)"
I think this solution is not right, because "char buf" is not guaranteed to have the correct alignment. Revert, and solve it differently. This reverts commit 6345a661535bd4aaf62b2ba4bee129762abb2954.
-rw-r--r--src/platform/nm-platform-utils.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/platform/nm-platform-utils.c b/src/platform/nm-platform-utils.c
index 492572833e..b0288bdbaa 100644
--- a/src/platform/nm-platform-utils.c
+++ b/src/platform/nm-platform-utils.c
@@ -335,25 +335,24 @@ _ethtool_call_once (int ifindex, gpointer edata, gsize edata_size)
static struct ethtool_gstrings *
ethtool_get_stringset (SocketHandle *shandle, int stringset_id)
{
- char buf[sizeof (struct ethtool_sset_info) + sizeof (guint32)];
- struct ethtool_sset_info *sset_info;
+ struct {
+ struct ethtool_sset_info info;
+ guint32 sentinel;
+ } sset_info = {
+ .info.cmd = ETHTOOL_GSSET_INFO,
+ .info.reserved = 0,
+ .info.sset_mask = (1ULL << stringset_id),
+ };
gs_free struct ethtool_gstrings *gstrings = NULL;
gsize gstrings_len;
guint32 i, len;
- sset_info = (struct ethtool_sset_info *) buf;
- *sset_info = (struct ethtool_sset_info) {
- .cmd = ETHTOOL_GSSET_INFO,
- .reserved = 0,
- .sset_mask = (1ULL << stringset_id),
- };
-
- if (_ethtool_call_handle (shandle, sset_info, sizeof (*sset_info)) < 0)
+ if (_ethtool_call_handle (shandle, &sset_info, sizeof (sset_info)) < 0)
return NULL;
- if (!sset_info->sset_mask)
+ if (!sset_info.info.sset_mask)
return NULL;
- len = sset_info->data[0];
+ len = sset_info.info.data[0];
gstrings_len = sizeof (*gstrings) + (len * ETH_GSTRING_LEN);
gstrings = g_malloc0 (gstrings_len);