core: avoid "-Wmaybe-uninitialized" warning in update_system_hostname() with LTO

When building without more-assertions and LTO, the compiler might think
that "wait" is uninitialized. Avoid the warning.

Initializing a variable is not a great solution either, because
potentially it could hide an actual bug. But it still seems to be
best.

    src/nm-policy.c: In function update_system_hostname:
    src/nm-policy.c:909: warning: wait may be used uninitialized in this function [-Wmaybe-uninitialized]
      909 |                     if (wait) {
          |
    src/nm-policy.c:901: note: wait was declared here
      901 |                     gboolean    wait;
          |
This commit is contained in:
Thomas Haller
2021-01-08 12:12:28 +01:00
parent 123765befc
commit f8026717e4

View File

@@ -898,7 +898,7 @@ update_system_hostname(NMPolicy *self, const char *msg)
if (info->from_dns && info->ip_x[IS_IPv4]) {
const char *result;
gboolean wait;
gboolean wait = FALSE;
result =
nm_device_get_hostname_from_dns_lookup(info->device, addr_family, &wait);