core: Drop "volatile" from static GTypes in manual registration

As documented in g_once_init_enter(): "While @location has a volatile qualifier,
this is a historical artifact and the pointer passed to it should not be
volatile.". And effectively this now warns with modern glibc.

Drop the "volatile" qualifier from these static variables as it's expected.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1785>
This commit is contained in:
Carlos Garnacho 2021-03-16 19:30:57 +01:00 committed by Marge Bot
parent bc1026d52d
commit dc9481973d
2 changed files with 12 additions and 14 deletions

View File

@ -13,9 +13,9 @@
GType GType
@enum_name@_get_type (void) @enum_name@_get_type (void)
{ {
static volatile gsize g_enum_type_id__volatile = 0; static size_t g_enum_type_id = 0;
if (g_once_init_enter (&g_enum_type_id__volatile)) if (g_once_init_enter (&g_enum_type_id))
{ {
static const G@Type@Value values[] = { static const G@Type@Value values[] = {
/*** END value-header ***/ /*** END value-header ***/
@ -27,14 +27,13 @@ GType
/*** BEGIN value-tail ***/ /*** BEGIN value-tail ***/
{ 0, NULL, NULL } { 0, NULL, NULL }
}; };
GType g_enum_type_id; GType id;
g_enum_type_id = id = g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);
g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);
g_once_init_leave (&g_enum_type_id__volatile, g_enum_type_id); g_once_init_leave (&g_enum_type_id, id);
} }
return g_enum_type_id__volatile; return g_enum_type_id;
} }
/*** END value-tail ***/ /*** END value-tail ***/

View File

@ -13,9 +13,9 @@
GType GType
@enum_name@_get_type (void) @enum_name@_get_type (void)
{ {
static volatile gsize g_enum_type_id__volatile = 0; static size_t g_enum_type_id = 0;
if (g_once_init_enter (&g_enum_type_id__volatile)) if (g_once_init_enter (&g_enum_type_id))
{ {
static const G@Type@Value values[] = { static const G@Type@Value values[] = {
/*** END value-header ***/ /*** END value-header ***/
@ -27,14 +27,13 @@ GType
/*** BEGIN value-tail ***/ /*** BEGIN value-tail ***/
{ 0, NULL, NULL } { 0, NULL, NULL }
}; };
GType g_enum_type_id; GType id;
g_enum_type_id = id = g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);
g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);
g_once_init_leave (&g_enum_type_id__volatile, g_enum_type_id); g_once_init_leave (&g_enum_type_id, id);
} }
return g_enum_type_id__volatile; return g_enum_type_id;
} }
/*** END value-tail ***/ /*** END value-tail ***/