[gnome-keyring/wip/smcv/fix-ci] Stop using volatile in conjunction with atomic operations




commit 7e64c48be84e91fd7b464d28f9ee650a332c169d
Author: Simon McVittie <smcv debian org>
Date:   Sun Sep 26 16:41:30 2021 +0100

    Stop using volatile in conjunction with atomic operations
    
    As discussed in <https://gitlab.gnome.org/GNOME/glib/-/issues/600>,
    the volatile qualifier rarely has the semantics that are desired in C/C++.
    With recent gcc versions, combining pointers to volatile-qualified types
    with the __atomic_foo() family of builtins causes compiler warnings.
    
    http://c.isvolatileusefulwiththreads.com/ has some other useful
    references.
    
    Signed-off-by: Simon McVittie <smcv debian org>

 daemon/dbus/gkd-secret-dispatch.c             |  2 +-
 daemon/dbus/gkd-secret-error.c                | 12 ++++++------
 daemon/ssh-agent/test-gkd-ssh-agent-service.c |  2 +-
 egg/egg-libgcrypt.c                           |  2 +-
 egg/egg-oid.c                                 |  2 +-
 egg/egg-symkey.c                              |  2 +-
 pkcs11/gkm/gkm-certificate.c                  |  2 +-
 pkcs11/gkm/gkm-data-der.c                     |  2 +-
 pkcs11/gkm/gkm-serializable.c                 |  8 ++++----
 pkcs11/secret-store/gkm-secret-fields.c       |  2 +-
 pkcs11/xdg-store/gkm-xdg-trust.c              |  2 +-
 11 files changed, 19 insertions(+), 19 deletions(-)
---
diff --git a/daemon/dbus/gkd-secret-dispatch.c b/daemon/dbus/gkd-secret-dispatch.c
index fed4c13e..a33106c2 100644
--- a/daemon/dbus/gkd-secret-dispatch.c
+++ b/daemon/dbus/gkd-secret-dispatch.c
@@ -25,7 +25,7 @@
 static void
 gkd_secret_dispatch_base_init (gpointer gobject_class)
 {
-       static volatile gsize initialized = 0;
+       static gsize initialized = 0;
        if (g_once_init_enter (&initialized)) {
                g_once_init_leave (&initialized, 1);
        }
diff --git a/daemon/dbus/gkd-secret-error.c b/daemon/dbus/gkd-secret-error.c
index f9012c30..ab0b20bc 100644
--- a/daemon/dbus/gkd-secret-error.c
+++ b/daemon/dbus/gkd-secret-error.c
@@ -38,13 +38,13 @@ static const GDBusErrorEntry gkd_secret_error_entries[] = {
 GQuark
 gkd_secret_error_quark (void)
 {
-       static volatile gsize quark_volatile = 0;
+       static gsize quark = 0;
 
        g_dbus_error_register_error_domain ("gkd_secret_error",
-                                           &quark_volatile,
+                                           &quark,
                                            gkd_secret_error_entries,
                                            G_N_ELEMENTS (gkd_secret_error_entries));
-       return quark_volatile;
+       return quark;
 }
 
 static const GDBusErrorEntry gkd_secret_daemon_error_entries[] = {
@@ -54,13 +54,13 @@ static const GDBusErrorEntry gkd_secret_daemon_error_entries[] = {
 GQuark
 gkd_secret_daemon_error_quark (void)
 {
-       static volatile gsize quark_volatile = 0;
+       static gsize quark = 0;
 
        g_dbus_error_register_error_domain ("gkd_secret_daemon_error",
-                                           &quark_volatile,
+                                           &quark,
                                            gkd_secret_daemon_error_entries,
                                            G_N_ELEMENTS (gkd_secret_daemon_error_entries));
-       return quark_volatile;
+       return quark;
 }
 
 void
diff --git a/daemon/ssh-agent/test-gkd-ssh-agent-service.c b/daemon/ssh-agent/test-gkd-ssh-agent-service.c
index 5c7a6179..1a127961 100644
--- a/daemon/ssh-agent/test-gkd-ssh-agent-service.c
+++ b/daemon/ssh-agent/test-gkd-ssh-agent-service.c
@@ -39,7 +39,7 @@ typedef struct {
        EggBuffer resp;
        GkdSshAgentService *service;
        GMainContext *server_thread_context;
-       volatile gint server_thread_stop;
+       gint server_thread_stop;
        GSocketConnection *connection;
        GThread *thread;
        GMutex lock;
diff --git a/egg/egg-libgcrypt.c b/egg/egg-libgcrypt.c
index 61fe115f..da2fd353 100644
--- a/egg/egg-libgcrypt.c
+++ b/egg/egg-libgcrypt.c
@@ -62,7 +62,7 @@ GCRY_THREAD_OPTION_PTHREAD_IMPL;
 void
 egg_libgcrypt_initialize (void)
 {
-       static volatile gsize gcrypt_initialized = 0;
+       static gsize gcrypt_initialized = 0;
        unsigned seed;
 
        if (g_once_init_enter (&gcrypt_initialized)) {
diff --git a/egg/egg-oid.c b/egg/egg-oid.c
index 96baea6d..fb3e3e06 100644
--- a/egg/egg-oid.c
+++ b/egg/egg-oid.c
@@ -115,7 +115,7 @@ static OidInfo oid_info[] = {
 static OidInfo*
 find_oid_info (GQuark oid)
 {
-       static volatile gsize inited_oids = 0;
+       static gsize inited_oids = 0;
        int i;
        
        g_return_val_if_fail (oid != 0, NULL);
diff --git a/egg/egg-symkey.c b/egg/egg-symkey.c
index 0f7a939f..80d4e66c 100644
--- a/egg/egg-symkey.c
+++ b/egg/egg-symkey.c
@@ -57,7 +57,7 @@ static GQuark OID_SHA1;
 static void
 init_quarks (void)
 {
-       static volatile gsize quarks_inited = 0;
+       static gsize quarks_inited = 0;
 
        if (g_once_init_enter (&quarks_inited)) {
 
diff --git a/pkcs11/gkm/gkm-certificate.c b/pkcs11/gkm/gkm-certificate.c
index 28ae0960..d434e527 100644
--- a/pkcs11/gkm/gkm-certificate.c
+++ b/pkcs11/gkm/gkm-certificate.c
@@ -74,7 +74,7 @@ G_DEFINE_TYPE_EXTENDED (GkmCertificate, gkm_certificate, GKM_TYPE_OBJECT, 0,
 static void
 init_quarks (void)
 {
-       static volatile gsize quarks_inited = 0;
+       static gsize quarks_inited = 0;
 
        if (g_once_init_enter (&quarks_inited)) {
                #define QUARK(name, value) \
diff --git a/pkcs11/gkm/gkm-data-der.c b/pkcs11/gkm/gkm-data-der.c
index 68f41d49..e7528022 100644
--- a/pkcs11/gkm/gkm-data-der.c
+++ b/pkcs11/gkm/gkm-data-der.c
@@ -52,7 +52,7 @@ static GQuark OID_ANSI_SECP521R1;
 static void
 init_quarks (void)
 {
-       static volatile gsize quarks_inited = 0;
+       static gsize quarks_inited = 0;
 
        if (g_once_init_enter (&quarks_inited)) {
 
diff --git a/pkcs11/gkm/gkm-serializable.c b/pkcs11/gkm/gkm-serializable.c
index ef7be957..7ebec114 100644
--- a/pkcs11/gkm/gkm-serializable.c
+++ b/pkcs11/gkm/gkm-serializable.c
@@ -37,9 +37,9 @@ gkm_serializable_base_init (gpointer gobject_class)
 GType
 gkm_serializable_get_type (void)
 {
-       static volatile gsize type_id__volatile = 0;
+       static gsize type_inited = 0;
 
-       if (g_once_init_enter (&type_id__volatile)) {
+       if (g_once_init_enter (&type_inited)) {
                static const GTypeInfo info = {
                        sizeof (GkmSerializableIface),
                        gkm_serializable_base_init,               /* base init */
@@ -55,10 +55,10 @@ gkm_serializable_get_type (void)
                GType type_id = g_type_register_static (G_TYPE_INTERFACE, "GkmSerializableIface", &info, 0);
                g_type_interface_add_prerequisite (type_id, G_TYPE_OBJECT);
 
-               g_once_init_leave (&type_id__volatile, type_id);
+               g_once_init_leave (&type_inited, type_id);
        }
 
-       return type_id__volatile;
+       return type_inited;
 }
 
 gboolean
diff --git a/pkcs11/secret-store/gkm-secret-fields.c b/pkcs11/secret-store/gkm-secret-fields.c
index 7e4559c6..71620499 100644
--- a/pkcs11/secret-store/gkm-secret-fields.c
+++ b/pkcs11/secret-store/gkm-secret-fields.c
@@ -124,7 +124,7 @@ compat_hash_value_as_string (const gchar *value)
 GType
 gkm_secret_fields_boxed_type (void)
 {
-       static volatile gsize type_inited = 0;
+       static gsize type_inited = 0;
        static GType type = 0;
 
        if (g_once_init_enter (&type_inited)) {
diff --git a/pkcs11/xdg-store/gkm-xdg-trust.c b/pkcs11/xdg-store/gkm-xdg-trust.c
index 518e3151..a18d6ebe 100644
--- a/pkcs11/xdg-store/gkm-xdg-trust.c
+++ b/pkcs11/xdg-store/gkm-xdg-trust.c
@@ -78,7 +78,7 @@ static GQuark TRUST_TRUSTED_ANCHOR;
 static void
 init_quarks (void)
 {
-       static volatile gsize quarks_inited = 0;
+       static gsize quarks_inited = 0;
 
        if (g_once_init_enter (&quarks_inited)) {
 


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