[mutter/wip/carlosg/volatile-warnings: 2/3] clutter: Drop "volatile" from static GTypes in manual registration




commit c4233e9324fc386648eb1ac46b1140c930a64ab4
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Mar 16 19:30:37 2021 +0100

    clutter: 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.

 clutter/clutter/clutter-enum-types.c.in   | 13 ++++++-------
 clutter/clutter/clutter-paint-node.c      | 10 +++++-----
 clutter/clutter/x11/clutter-backend-x11.c | 10 +++++-----
 3 files changed, 16 insertions(+), 17 deletions(-)
---
diff --git a/clutter/clutter/clutter-enum-types.c.in b/clutter/clutter/clutter-enum-types.c.in
index de2cb26d0e..50f9bbf4b3 100644
--- a/clutter/clutter/clutter-enum-types.c.in
+++ b/clutter/clutter/clutter-enum-types.c.in
@@ -14,9 +14,9 @@
 GType
 @enum_name@_get_type (void)
 {
-  static volatile gsize g_enum_type_id__volatile = 0;
+  static gsize 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[] = {
 /*** END value-header ***/
@@ -28,14 +28,13 @@ GType
 /*** BEGIN value-tail ***/
         { 0, NULL, NULL }
       };
-      GType g_enum_type_id;
+      GType id;
 
-      g_enum_type_id =
-        g_@type@_register_static (g_intern_static_string ("@EnumName@"), values);
+      id = 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 ***/
diff --git a/clutter/clutter/clutter-paint-node.c b/clutter/clutter/clutter-paint-node.c
index 27142af873..f98cd8aa43 100644
--- a/clutter/clutter/clutter-paint-node.c
+++ b/clutter/clutter/clutter-paint-node.c
@@ -234,9 +234,9 @@ clutter_paint_node_init (ClutterPaintNode *self)
 GType
 clutter_paint_node_get_type (void)
 {
-  static volatile gsize paint_node_type_id__volatile = 0;
+  static gsize paint_node_type_id = 0;
 
-  if (g_once_init_enter (&paint_node_type_id__volatile))
+  if (g_once_init_enter (&paint_node_type_id))
     {
       static const GTypeFundamentalInfo finfo = {
         (G_TYPE_FLAG_CLASSED |
@@ -272,16 +272,16 @@ clutter_paint_node_get_type (void)
         &value_table,
       };
 
-      GType paint_node_type_id =
+      GType id =
         g_type_register_fundamental (g_type_fundamental_next (),
                                      I_("ClutterPaintNode"),
                                      &node_info, &finfo,
                                      G_TYPE_FLAG_ABSTRACT);
 
-      g_once_init_leave (&paint_node_type_id__volatile, paint_node_type_id);
+      g_once_init_leave (&paint_node_type_id, id);
     }
 
-  return paint_node_type_id__volatile;
+  return paint_node_type_id;
 }
 
 /**
diff --git a/clutter/clutter/x11/clutter-backend-x11.c b/clutter/clutter/x11/clutter-backend-x11.c
index a46aa340de..65671654ee 100644
--- a/clutter/clutter/x11/clutter-backend-x11.c
+++ b/clutter/clutter/x11/clutter-backend-x11.c
@@ -57,9 +57,9 @@ G_DEFINE_TYPE (ClutterBackendX11, clutter_backend_x11, CLUTTER_TYPE_BACKEND)
 GType
 clutter_x11_filter_return_get_type (void)
 {
-  static volatile gsize g_define_type__volatile;
+  static gsize g_define_type;
 
-  if (g_once_init_enter (&g_define_type__volatile))
+  if (g_once_init_enter (&g_define_type))
     {
       static const GEnumValue values[] = {
         { CLUTTER_X11_FILTER_CONTINUE, "CLUTTER_X11_FILTER_CONTINUE", "continue" },
@@ -68,13 +68,13 @@ clutter_x11_filter_return_get_type (void)
         { 0, NULL, NULL },
       };
 
-      GType g_define_type =
+      GType id =
         g_enum_register_static (g_intern_static_string ("ClutterX11FilterReturn"), values);
 
-      g_once_init_leave (&g_define_type__volatile, g_define_type);
+      g_once_init_leave (&g_define_type, id);
     }
 
-  return g_define_type__volatile;
+  return g_define_type;
 }
 
 /* atoms; remember to add the code that assigns the atom value to


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]