mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-28 01:40:33 +01:00
glib-aux: workaround maybe-uninitialized warning with LTO in nm_uuid_generate_from_string_str()
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.
(cherry picked from commit cb9ca67901)
(cherry picked from commit 634e023e72)
This commit is contained in:
parent
4fa6001c60
commit
796ba8dcd1
1 changed files with 8 additions and 2 deletions
|
|
@ -382,9 +382,15 @@ nm_uuid_generate_from_string_str(const char *s,
|
|||
NMUuidType uuid_type,
|
||||
gpointer type_args)
|
||||
{
|
||||
NMUuid uuid;
|
||||
NMUuid uuid;
|
||||
const NMUuid *u;
|
||||
|
||||
u = nm_uuid_generate_from_string(&uuid, s, slen, uuid_type, type_args);
|
||||
|
||||
if (G_UNLIKELY(!u))
|
||||
return nm_assert_unreachable_val(NULL);
|
||||
nm_assert(u == &uuid);
|
||||
|
||||
nm_uuid_generate_from_string(&uuid, s, slen, uuid_type, type_args);
|
||||
return nm_uuid_unparse(&uuid, g_new(char, 37));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue