summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2021-01-13 08:34:42 +0100
committerThomas Haller <thaller@redhat.com>2021-01-13 08:35:22 +0100
commit828e47f63275fce8ea0fd9b8510519fd3e3144a5 (patch)
treecd7a9ee64a7d9b34b5e0ec0bba98285384882b74
parent54feadd2c1989af865d36abdfb5f20b8a7bbf91e (diff)
downloadNetworkManager-828e47f63275fce8ea0fd9b8510519fd3e3144a5.tar.gz
device: set out-argument to nm_device_get_permanent_hw_address_full() in assertion case
When compiling with LTO, the compiler can think that an assertion failure (g_return*()) is regular code path, and thus that the output variable is not set. This can lead to "-Wmaybe-uninitialized" warnings in the caller, despite this not happening in non-bug case. Work aound that by setting the out argument. Warning with LTO enabled and gcc-10.2.1-9.fc33.s390x: src/nm-config-data.c: In function nm_config_data_get_device_config: src/devices/nm-device.c:17454:9: error: is_fake may be used uninitialized in this function [-Werror=maybe-uninitialized] 17454 | m = nm_match_spec_device(specs, | ^ src/devices/nm-device.c:17444:26: note: is_fake was declared here 17444 | gboolean is_fake; | ^ src/nm-config-data.c: In function nm_config_data_get_connection_default: src/devices/nm-device.c:17454:9: error: is_fake may be used uninitialized in this function [-Werror=maybe-uninitialized] 17454 | m = nm_match_spec_device(specs, | ^ src/devices/nm-device.c:17444:26: note: is_fake was declared here 17444 | gboolean is_fake; | ^ src/devices/nm-device.c: In function nm_device_check_unrealized_device_managed: src/devices/nm-device.c:17454:9: error: is_fake may be used uninitialized in this function [-Werror=maybe-uninitialized] 17454 | m = nm_match_spec_device(specs, | ^
-rw-r--r--src/devices/nm-device.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index f6749bb041..3ab81df0fa 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -17379,7 +17379,10 @@ nm_device_get_permanent_hw_address_full(NMDevice *self,
{
NMDevicePrivate *priv;
- g_return_val_if_fail(NM_IS_DEVICE(self), NULL);
+ g_return_val_if_fail(NM_IS_DEVICE(self), ({
+ NM_SET_OUT(out_is_fake, FALSE);
+ NULL;
+ }));
priv = NM_DEVICE_GET_PRIVATE(self);