summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-02-10 10:57:10 +0100
committerThomas Haller <thaller@redhat.com>2020-02-10 11:26:59 +0100
commit0931c4f2eaa2092e622dba8f58deb91760c4b53d (patch)
tree4134606c638e7f52e19c758a9e51e907e895b6f9
parent1fd7e4513976d31509f4ad43c425f1b92e77e835 (diff)
downloadNetworkManager-0931c4f2eaa2092e622dba8f58deb91760c4b53d.tar.gz
Revert "platform: fix GCC warning about zero-lenght array (2)"
This reverts commit 5076fc0ca0e22b3db7987df561922d9efa840f26.
-rw-r--r--src/platform/nm-platform-utils.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/src/platform/nm-platform-utils.c b/src/platform/nm-platform-utils.c
index b0288bdbaa..4f0da581d0 100644
--- a/src/platform/nm-platform-utils.c
+++ b/src/platform/nm-platform-utils.c
@@ -831,42 +831,41 @@ nmp_utils_ethtool_get_permanent_address (int ifindex,
guint8 *buf,
size_t *length)
{
- char ebuf[sizeof (struct ethtool_perm_addr) + NM_UTILS_HWADDR_LEN_MAX + 1];
- struct ethtool_perm_addr *edata;
+ struct {
+ struct ethtool_perm_addr e;
+ guint8 _extra_data[NM_UTILS_HWADDR_LEN_MAX + 1];
+ } edata = {
+ .e.cmd = ETHTOOL_GPERMADDR,
+ .e.size = NM_UTILS_HWADDR_LEN_MAX,
+ };
guint i;
g_return_val_if_fail (ifindex > 0, FALSE);
- edata = (struct ethtool_perm_addr *) ebuf;
- *edata = (struct ethtool_perm_addr) {
- .cmd = ETHTOOL_GPERMADDR,
- .size = NM_UTILS_HWADDR_LEN_MAX,
- };
-
- if (_ethtool_call_once (ifindex, edata, sizeof (*edata)) < 0)
+ if (_ethtool_call_once (ifindex, &edata, sizeof (edata)) < 0)
return FALSE;
- if (edata->size > NM_UTILS_HWADDR_LEN_MAX)
+ if (edata.e.size > NM_UTILS_HWADDR_LEN_MAX)
return FALSE;
- if (edata->size < 1)
+ if (edata.e.size < 1)
return FALSE;
- if (NM_IN_SET (edata->data[0], 0, 0xFF)) {
+ if (NM_IN_SET (edata.e.data[0], 0, 0xFF)) {
/* Some drivers might return a permanent address of all zeros.
* Reject that (rh#1264024)
*
* Some drivers return a permanent address of all ones. Reject that too */
- for (i = 1; i < edata->size; i++) {
- if (edata->data[0] != edata->data[i])
+ for (i = 1; i < edata.e.size; i++) {
+ if (edata.e.data[0] != edata.e.data[i])
goto not_all_0or1;
}
return FALSE;
}
not_all_0or1:
- memcpy (buf, edata->data, edata->size);
- *length = edata->size;
+ memcpy (buf, edata.e.data, edata.e.size);
+ *length = edata.e.size;
return TRUE;
}