diff options
author | Thomas Haller <thaller@redhat.com> | 2021-01-12 16:32:58 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2021-01-12 16:32:59 +0100 |
commit | 63a33b35420f128f939d1e0da2fc1b22b7a62b04 (patch) | |
tree | bceb7c377b1a4b642d2b91d0c1e7a49fa72b66ba | |
parent | d26fa1cd52f7e1e9d49cebc493ca4631c10bcdeb (diff) | |
download | NetworkManager-63a33b35420f128f939d1e0da2fc1b22b7a62b04.tar.gz |
libnm: avoid "-Wmaybe-uninitialized" warning in nm_setting_ethtool_get_optnames()
With LTO build on s390x (Fedora 33) we get a compiler warning:
libnm-core/nm-setting-ethtool.c: In function 'nm_setting_ethtool_get_optnames':
libnm-core/nm-setting-ethtool.c:263:60: error: 'len' may be used uninitialized in this function [-Werror=maybe-uninitialized]
263 | return len > 0 ? nm_memdup(names, sizeof(names[0]) * (((gsize) len) + 1u)) : NULL;
| ^
libnm-core/nm-setting-ethtool.c:257:24: note: 'len' was declared here
257 | guint len;
| ^
libnm-core/nm-setting-ethtool.c: In function 'nm_setting_ethtool_get_optnames':
libnm-core/nm-setting-ethtool.c:263:60: error: 'len' may be used uninitialized in this function [-Werror=maybe-uninitialized]
263 | return len > 0 ? nm_memdup(names, sizeof(names[0]) * (((gsize) len) + 1u)) : NULL;
| ^
libnm-core/nm-setting-ethtool.c:257:24: note: 'len' was declared here
257 | guint len;
| ^
-rw-r--r-- | libnm-core/nm-setting-ethtool.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libnm-core/nm-setting-ethtool.c b/libnm-core/nm-setting-ethtool.c index dc94406036..f1d6a8786c 100644 --- a/libnm-core/nm-setting-ethtool.c +++ b/libnm-core/nm-setting-ethtool.c @@ -254,7 +254,7 @@ const char ** nm_setting_ethtool_get_optnames(NMSettingEthtool *setting, guint *out_length) { const char *const *names; - guint len; + guint len = 0; g_return_val_if_fail(NM_IS_SETTING_ETHTOOL(setting), NULL); |