Skip to content
  • Thomas Haller's avatar
    glib-aux: workaround maybe-uninitialized warning with LTO in nm_uuid_generate_from_string_str() · cb9ca679
    Thomas Haller authored
      In function 'nm_uuid_unparse',
          inlined from 'nm_uuid_generate_from_string_str' at src/libnm-glib-aux/nm-uuid.c:393:12,
          inlined from 'nm_uuid_generate_from_strings.constprop' at src/libnm-glib-aux/nm-uuid.c:430:16:
      src/libnm-glib-aux/nm-uuid.h:37:12: error: 'uuid' may be used uninitialized [-Werror=maybe-uninitialized]
         37 |     return nm_uuid_unparse_case(uuid, out_str, FALSE);
            |            ^
      src/libnm-glib-aux/nm-uuid.c: In function 'nm_uuid_generate_from_strings.constprop':
      src/libnm-glib-aux/nm-uuid.c:20:1: note: by argument 1 of type 'const struct NMUuid *' to 'nm_uuid_unparse_case.constprop' declared here
         20 | nm_uuid_unparse_case(const NMUuid *uuid, char out_str[static 37], gboolean upper_case)
            | ^
      src/libnm-glib-aux/nm-uuid.c:390:12: note: 'uuid' declared here
        390 |     NMUuid uuid;
            |            ^
      lto1: all warnings being treated as errors
    
    The problem are code paths with failed g_return*() assertions. Being in
    a bad state already, they don't bother to ensure proper return values,
    and with LTO the compiler might think there are valid code paths wrongly
    handled. Work around.
    cb9ca679