Drop use of `volatile`
authorJonathan Lebon <jonathan@jlebon.com>
Mon, 2 Nov 2020 19:53:26 +0000 (14:53 -0500)
committerJonathan Lebon <jonathan@jlebon.com>
Mon, 2 Nov 2020 19:53:26 +0000 (14:53 -0500)
As detailed in
gitlab.gnome.org/GNOME/glib/-/issues/600#note_877282, volatile
isn't actually needed in these contexts because the atomic operations
already give us strong enough guarantees. In GCC 11, this triggers a
diagnostic due to the volatile qualifier getting dropped anyway.

There is a WIP to do the same in glib:
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719

This obsoletes this downstream patch:
https://src.fedoraproject.org/rpms/ostree/c/b8c5a6fb

src/libostree/ostree-diff.h
src/libostree/ostree-enumtypes.c.template
src/libostree/ostree-fetcher-soup.c
src/libostree/ostree-remote-private.h
src/libostree/ostree-repo-private.h
src/libostree/ostree-sysroot-upgrader.c

index 1c0024a235c3b0407cd07c1ecac49f297f35f198..b53125ac05debb406ab09aba6543135cad11ef8a 100644 (file)
@@ -42,7 +42,7 @@ typedef enum {
 typedef struct _OstreeDiffItem OstreeDiffItem;
 struct _OstreeDiffItem
 {
-  volatile gint refcount;
+  gint refcount;  /* atomic */
 
   GFile *src;
   GFile *target;
index 751c458a9f9946af114a5f67516061b05ec2e9ca..827ad911cbf97cc5676778e95db6761c1df01de5 100644 (file)
@@ -36,9 +36,9 @@
 GType
 _@enum_name@_get_type (void)
 {
-  static volatile gsize the_type__volatile = 0;
+  static gsize static_the_type = 0;
 
-  if (g_once_init_enter (&the_type__volatile))
+  if (g_once_init_enter (&static_the_type))
     {
       static const G@Type@Value values[] = {
 /*** END value-header ***/
@@ -57,10 +57,10 @@ _@enum_name@_get_type (void)
         g_intern_static_string ("@EnumName@"),
         values);
 
-      g_once_init_leave (&the_type__volatile, the_type);
+      g_once_init_leave (&static_the_type, the_type);
     }
 
-  return the_type__volatile;
+  return static_the_type;
 }
 
 /*** END value-tail ***/
index 52fe5fc38d232f1947d3638c5ecbab6d16e9a920..e1e5002e7e34127e6be7480173da0cca8a15f04d 100644 (file)
@@ -49,7 +49,7 @@ typedef enum {
 } OstreeFetcherState;
 
 typedef struct {
-  volatile int ref_count;
+  int ref_count;  /* atomic */
 
   SoupSession *session;  /* not referenced */
   GMainContext *main_context;
@@ -77,7 +77,7 @@ typedef struct {
 } ThreadClosure;
 
 typedef struct {
-  volatile int ref_count;
+  int ref_count;  /* atomic */
 
   ThreadClosure *thread_closure;
   GPtrArray *mirrorlist; /* list of base URIs */
index 061412de7507476081907c032beec3295935bff3..bf74f6137ba9745288e5e6c0d874209f1eda9d1c 100644 (file)
@@ -41,7 +41,7 @@ G_BEGIN_DECLS
  * remote which this one inherits from, and is what should be used in refspecs
  * for pulls from this remote. If it’s %NULL, @name should be used instead. */
 struct OstreeRemote {
-  volatile int ref_count;
+  int ref_count;  /* atomic */
   char *name;  /* (not nullable) */
   char *refspec_name;  /* (nullable) */
   char *group;   /* group name in options (not nullable) */
index 628f2b469a7c76c7b388733399a8820b09b9cc49..714fda8ba9cca2e9655f9145a767586950049cfb 100644 (file)
@@ -72,7 +72,7 @@ typedef enum {
 } OstreeRepoTestErrorFlags;
 
 struct OstreeRepoCommitModifier {
-  volatile gint refcount;
+  gint refcount;  /* atomic */
 
   OstreeRepoCommitModifierFlags flags;
   OstreeRepoCommitFilter filter;
index 468133580edbc853282c234c002567c4bb83007a..85e6734033c41f88cb2aeaaf3c5350b2618e9a6e 100644 (file)
@@ -682,9 +682,9 @@ ostree_sysroot_upgrader_deploy (OstreeSysrootUpgrader  *self,
 GType
 ostree_sysroot_upgrader_flags_get_type (void)
 {
-  static volatile gsize g_define_type_id__volatile = 0;
+  static gsize static_g_define_type_id = 0;
 
-  if (g_once_init_enter (&g_define_type_id__volatile))
+  if (g_once_init_enter (&static_g_define_type_id))
     {
       static const GFlagsValue values[] = {
         { OSTREE_SYSROOT_UPGRADER_FLAGS_IGNORE_UNCONFIGURED, "OSTREE_SYSROOT_UPGRADER_FLAGS_IGNORE_UNCONFIGURED", "ignore-unconfigured" },
@@ -692,8 +692,8 @@ ostree_sysroot_upgrader_flags_get_type (void)
       };
       GType g_define_type_id =
         g_flags_register_static (g_intern_static_string ("OstreeSysrootUpgraderFlags"), values);
-      g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
+      g_once_init_leave (&static_g_define_type_id, g_define_type_id);
     }
 
-  return g_define_type_id__volatile;
+  return static_g_define_type_id;
 }