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,
          |         ^
This commit is contained in:
Thomas Haller 2021-01-13 08:34:42 +01:00
parent 54feadd2c1
commit 828e47f632
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -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);