From a1dfecf11f6f4485e947a7071746f018ae34f95e Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Mon, 11 Sep 2023 23:59:52 -0700 Subject: [PATCH] Use g_once_init_{enter,leave}_pointer where appropriate This should not result in any functional changes, but will eventually allow glib to be functional on CHERI-enabled systems such as Morello. Helps: https://gitlab.gnome.org/GNOME/glib/-/issues/2842 --- gio/gdbusprivate.c | 12 +++++------- gio/gdesktopappinfo.c | 12 ++++++------ gio/gdummytlsbackend.c | 4 ++-- gio/ginetsocketaddress.c | 4 ++-- gio/glocalfile.c | 6 +++--- gio/gnetworkmonitor.c | 4 ++-- gio/gproxyresolver.c | 4 ++-- gio/gresource.c | 4 ++-- gio/gsettingsbackend.c | 4 ++-- gio/gsettingsschema.c | 12 ++++++------ gio/gsocket.c | 4 ++-- gio/gtestdbus.c | 15 ++++++--------- gio/gtlsbackend.c | 4 ++-- gio/gtrashportal.c | 4 ++-- gio/gvfs.c | 12 ++++++------ gio/gwin32registrykey.c | 16 ++++++++-------- gio/inotify/inotify-kernel.c | 4 ++-- glib/gcharset.c | 4 ++-- glib/gmain.c | 4 ++-- glib/gtestutils.c | 6 +++--- glib/gutils.c | 8 ++++---- glib/tests/once.c | 4 ++-- glib/tests/onceinit.c | 8 ++++---- gobject/gobject.c | 4 ++-- gobject/gtype.c | 4 ++-- 25 files changed, 81 insertions(+), 86 deletions(-) diff --git a/gio/gdbusprivate.c b/gio/gdbusprivate.c index 2c9238c63..a777b7943 100644 --- a/gio/gdbusprivate.c +++ b/gio/gdbusprivate.c @@ -294,10 +294,9 @@ gdbus_shared_thread_func (gpointer user_data) static SharedThreadData * _g_dbus_shared_thread_ref (void) { - static gsize shared_thread_data = 0; - SharedThreadData *ret; + static SharedThreadData *shared_thread_data = 0; - if (g_once_init_enter (&shared_thread_data)) + if (g_once_init_enter_pointer (&shared_thread_data)) { SharedThreadData *data; @@ -310,12 +309,11 @@ _g_dbus_shared_thread_ref (void) gdbus_shared_thread_func, data); /* We can cast between gsize and gpointer safely */ - g_once_init_leave (&shared_thread_data, (gsize) data); + g_once_init_leave_pointer (&shared_thread_data, data); } - ret = (SharedThreadData*) shared_thread_data; - g_atomic_int_inc (&ret->refcount); - return ret; + g_atomic_int_inc (&shared_thread_data->refcount); + return shared_thread_data; } static void diff --git a/gio/gdesktopappinfo.c b/gio/gdesktopappinfo.c index eaaf79273..292d7aa3b 100644 --- a/gio/gdesktopappinfo.c +++ b/gio/gdesktopappinfo.c @@ -365,7 +365,7 @@ get_lowercase_current_desktops (void) { static gchar **result; - if (g_once_init_enter (&result)) + if (g_once_init_enter_pointer (&result)) { char **tmp = get_valid_current_desktops (NULL); gsize i, j; @@ -377,7 +377,7 @@ get_lowercase_current_desktops (void) tmp[i][j] = g_ascii_tolower (tmp[i][j]); } - g_once_init_leave (&result, tmp); + g_once_init_leave_pointer (&result, tmp); } return (const gchar **) result; @@ -388,11 +388,11 @@ get_current_desktops (const gchar *value) { static gchar **result; - if (g_once_init_enter (&result)) + if (g_once_init_enter_pointer (&result)) { char **tmp = get_valid_current_desktops (value); - g_once_init_leave (&result, tmp); + g_once_init_leave_pointer (&result, tmp); } return (const gchar **) result; @@ -3012,7 +3012,7 @@ g_desktop_app_info_launch_uris_with_spawn (GDesktopAppInfo *info, g_free (program); } - if (g_once_init_enter (&gio_launch_desktop_path)) + if (g_once_init_enter_pointer (&gio_launch_desktop_path)) { const gchar *tmp = NULL; gboolean is_setuid = GLIB_PRIVATE_CALL (g_check_setuid) (); @@ -3028,7 +3028,7 @@ g_desktop_app_info_launch_uris_with_spawn (GDesktopAppInfo *info, /* Fall back on usual searching in $PATH */ if (tmp == NULL) tmp = "gio-launch-desktop"; - g_once_init_leave (&gio_launch_desktop_path, tmp); + g_once_init_leave_pointer (&gio_launch_desktop_path, tmp); } wrapped_argv = g_new (char *, argc + 2); diff --git a/gio/gdummytlsbackend.c b/gio/gdummytlsbackend.c index 1ec00c99e..4c69f1d01 100644 --- a/gio/gdummytlsbackend.c +++ b/gio/gdummytlsbackend.c @@ -93,12 +93,12 @@ g_dummy_tls_backend_get_default_database (GTlsBackend *backend) { GDummyTlsBackend *dummy = G_DUMMY_TLS_BACKEND (backend); - if (g_once_init_enter (&dummy->database)) + if (g_once_init_enter_pointer (&dummy->database)) { GTlsDatabase *tlsdb; tlsdb = g_object_new (_g_dummy_tls_database_get_type (), NULL); - g_once_init_leave (&dummy->database, tlsdb); + g_once_init_leave_pointer (&dummy->database, tlsdb); } return g_object_ref (dummy->database); diff --git a/gio/ginetsocketaddress.c b/gio/ginetsocketaddress.c index 769303558..0dee6468f 100644 --- a/gio/ginetsocketaddress.c +++ b/gio/ginetsocketaddress.c @@ -421,13 +421,13 @@ g_inet_socket_address_new_from_string (const char *address, * it will handle parsing a scope_id as well. */ - if (G_UNLIKELY (g_once_init_enter (&hints))) + if (G_UNLIKELY (g_once_init_enter_pointer (&hints))) { hints_struct.ai_family = AF_UNSPEC; hints_struct.ai_socktype = SOCK_STREAM; hints_struct.ai_protocol = 0; hints_struct.ai_flags = AI_NUMERICHOST; - g_once_init_leave (&hints, &hints_struct); + g_once_init_leave_pointer (&hints, &hints_struct); } status = getaddrinfo (address, NULL, hints, &res); diff --git a/gio/glocalfile.c b/gio/glocalfile.c index dbb56902d..b7b9b629d 100644 --- a/gio/glocalfile.c +++ b/gio/glocalfile.c @@ -105,7 +105,7 @@ static void g_local_file_file_iface_init (GFileIface *iface); static GFileAttributeInfoList *local_writable_attributes = NULL; -static /* GFileAttributeInfoList * */ gsize local_writable_namespaces = 0; +static GFileAttributeInfoList *local_writable_namespaces = NULL; struct _GLocalFile { @@ -1274,7 +1274,7 @@ g_local_file_query_writable_namespaces (GFile *file, GVfsClass *class; GVfs *vfs; - if (g_once_init_enter (&local_writable_namespaces)) + if (g_once_init_enter_pointer (&local_writable_namespaces)) { /* Writable namespaces: */ @@ -1297,7 +1297,7 @@ g_local_file_query_writable_namespaces (GFile *file, if (class->add_writable_namespaces) class->add_writable_namespaces (vfs, list); - g_once_init_leave (&local_writable_namespaces, (gsize)list); + g_once_init_leave_pointer (&local_writable_namespaces, list); } list = (GFileAttributeInfoList *)local_writable_namespaces; diff --git a/gio/gnetworkmonitor.c b/gio/gnetworkmonitor.c index 37f2faa6d..f017b168b 100644 --- a/gio/gnetworkmonitor.c +++ b/gio/gnetworkmonitor.c @@ -94,7 +94,7 @@ static GNetworkMonitor *network_monitor_default_singleton = NULL; /* (owned) (a GNetworkMonitor * g_network_monitor_get_default (void) { - if (g_once_init_enter (&network_monitor_default_singleton)) + if (g_once_init_enter_pointer (&network_monitor_default_singleton)) { GNetworkMonitor *singleton; @@ -102,7 +102,7 @@ g_network_monitor_get_default (void) "GIO_USE_NETWORK_MONITOR", NULL); - g_once_init_leave (&network_monitor_default_singleton, singleton); + g_once_init_leave_pointer (&network_monitor_default_singleton, singleton); } return network_monitor_default_singleton; diff --git a/gio/gproxyresolver.c b/gio/gproxyresolver.c index 4a4855a44..c24323404 100644 --- a/gio/gproxyresolver.c +++ b/gio/gproxyresolver.c @@ -84,7 +84,7 @@ static GProxyResolver *proxy_resolver_default_singleton = NULL; /* (owned) (ato GProxyResolver * g_proxy_resolver_get_default (void) { - if (g_once_init_enter (&proxy_resolver_default_singleton)) + if (g_once_init_enter_pointer (&proxy_resolver_default_singleton)) { GProxyResolver *singleton; @@ -92,7 +92,7 @@ g_proxy_resolver_get_default (void) "GIO_USE_PROXY_RESOLVER", (GIOModuleVerifyFunc) g_proxy_resolver_is_supported); - g_once_init_leave (&proxy_resolver_default_singleton, singleton); + g_once_init_leave_pointer (&proxy_resolver_default_singleton, singleton); } return proxy_resolver_default_singleton; diff --git a/gio/gresource.c b/gio/gresource.c index a67df11ef..9965e2698 100644 --- a/gio/gresource.c +++ b/gio/gresource.c @@ -336,7 +336,7 @@ g_resource_find_overlay (const gchar *path, * we can take a bit more time... */ - if (g_once_init_enter (&overlay_dirs)) + if (g_once_init_enter_pointer (&overlay_dirs)) { gboolean is_setuid = GLIB_PRIVATE_CALL (g_check_setuid) (); const gchar * const *result; @@ -420,7 +420,7 @@ g_resource_find_overlay (const gchar *path, result = empty_strv; } - g_once_init_leave (&overlay_dirs, result); + g_once_init_leave_pointer (&overlay_dirs, result); } for (i = 0; overlay_dirs[i]; i++) diff --git a/gio/gsettingsbackend.c b/gio/gsettingsbackend.c index 2db6c5815..bc9400875 100644 --- a/gio/gsettingsbackend.c +++ b/gio/gsettingsbackend.c @@ -1018,7 +1018,7 @@ static GSettingsBackend *settings_backend_default_singleton = NULL; /* (owned) GSettingsBackend * g_settings_backend_get_default (void) { - if (g_once_init_enter (&settings_backend_default_singleton)) + if (g_once_init_enter_pointer (&settings_backend_default_singleton)) { GSettingsBackend *singleton; @@ -1026,7 +1026,7 @@ g_settings_backend_get_default (void) "GSETTINGS_BACKEND", g_settings_backend_verify); - g_once_init_leave (&settings_backend_default_singleton, singleton); + g_once_init_leave_pointer (&settings_backend_default_singleton, singleton); } return g_object_ref (settings_backend_default_singleton); diff --git a/gio/gsettingsschema.c b/gio/gsettingsschema.c index b3ac2f189..2a2da65fd 100644 --- a/gio/gsettingsschema.c +++ b/gio/gsettingsschema.c @@ -580,7 +580,7 @@ normalise_whitespace (const gchar *orig) gchar *result; gint i; - if (g_once_init_enter (&splitter)) + if (g_once_init_enter_pointer (&splitter)) { GRegex *s; @@ -593,7 +593,7 @@ normalise_whitespace (const gchar *orig) s = g_regex_new ("\\n\\s*\\n+", G_REGEX_DEFAULT, G_REGEX_MATCH_DEFAULT, NULL); - g_once_init_leave (&splitter, s); + g_once_init_leave_pointer (&splitter, s); } lines = g_regex_split (splitter, orig, 0); @@ -744,7 +744,7 @@ parse_into_text_tables (const gchar *directory, static GHashTable ** g_settings_schema_source_get_text_tables (GSettingsSchemaSource *source) { - if (g_once_init_enter (&source->text_tables)) + if (g_once_init_enter_pointer (&source->text_tables)) { GHashTable **text_tables; @@ -755,7 +755,7 @@ g_settings_schema_source_get_text_tables (GSettingsSchemaSource *source) if (source->directory) parse_into_text_tables (source->directory, text_tables[0], text_tables[1]); - g_once_init_leave (&source->text_tables, text_tables); + g_once_init_leave_pointer (&source->text_tables, text_tables); } return source->text_tables; @@ -1496,7 +1496,7 @@ g_settings_schema_key_get_per_desktop_default (GSettingsSchemaKey *key) if (!key->desktop_overrides) return NULL; - if (g_once_init_enter (¤t_desktops)) + if (g_once_init_enter_pointer (¤t_desktops)) { const gchar *xdg_current_desktop = g_getenv ("XDG_CURRENT_DESKTOP"); gchar **tmp; @@ -1506,7 +1506,7 @@ g_settings_schema_key_get_per_desktop_default (GSettingsSchemaKey *key) else tmp = g_new0 (gchar *, 0 + 1); - g_once_init_leave (¤t_desktops, (const gchar **) tmp); + g_once_init_leave_pointer (¤t_desktops, (const gchar **) tmp); } for (i = 0; value == NULL && current_desktops[i] != NULL; i++) diff --git a/gio/gsocket.c b/gio/gsocket.c index a4b57d909..8689cf97c 100644 --- a/gio/gsocket.c +++ b/gio/gsocket.c @@ -3179,8 +3179,8 @@ g_socket_get_available_bytes (GSocket *socket) #else if (socket->priv->type == G_SOCKET_TYPE_DATAGRAM) { - if (G_UNLIKELY (g_once_init_enter (&buf))) - g_once_init_leave (&buf, g_malloc (bufsize)); + if (G_UNLIKELY (g_once_init_enter_pointer (&buf))) + g_once_init_leave_pointer (&buf, g_malloc (bufsize)); /* On datagram sockets, FIONREAD ioctl is not reliable because many * systems add internal header size to the reported size, making it diff --git a/gio/gtestdbus.c b/gio/gtestdbus.c index d75b4395a..2f93c229d 100644 --- a/gio/gtestdbus.c +++ b/gio/gtestdbus.c @@ -121,25 +121,22 @@ _g_object_unref_and_wait_weak_notify (gpointer object) static void _g_test_watcher_add_pid (GPid pid) { - static gsize started = 0; - HANDLE job; + HANDLE job = NULL; - if (g_once_init_enter (&started)) + if (g_once_init_enter (&job)) { JOBOBJECT_EXTENDED_LIMIT_INFORMATION info; - job = CreateJobObjectW (NULL, NULL); + HANDLE tmp = CreateJobObjectW (NULL, NULL); memset (&info, 0, sizeof (info)); info.BasicLimitInformation.LimitFlags = 0x2000 /* JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE */; - if (!SetInformationJobObject(job, JobObjectExtendedLimitInformation, &info, sizeof (info))) - g_warning ("Can't enable JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE: %s", g_win32_error_message (GetLastError())); + if (!SetInformationJobObject (tmp, JobObjectExtendedLimitInformation, &info, sizeof (info))) + g_warning ("Can't enable JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE: %s", g_win32_error_message (GetLastError())); - g_once_init_leave (&started,(gsize)job); + g_once_init_leave_pointer (&job, tmp); } - job = (HANDLE)started; - if (!AssignProcessToJobObject(job, pid)) g_warning ("Can't assign process to job: %s", g_win32_error_message (GetLastError())); } diff --git a/gio/gtlsbackend.c b/gio/gtlsbackend.c index 227dd7701..39c5ef241 100644 --- a/gio/gtlsbackend.c +++ b/gio/gtlsbackend.c @@ -110,7 +110,7 @@ static GTlsBackend *tls_backend_default_singleton = NULL; /* (owned) (atomic) * GTlsBackend * g_tls_backend_get_default (void) { - if (g_once_init_enter (&tls_backend_default_singleton)) + if (g_once_init_enter_pointer (&tls_backend_default_singleton)) { GTlsBackend *singleton; @@ -118,7 +118,7 @@ g_tls_backend_get_default (void) "GIO_USE_TLS", NULL); - g_once_init_leave (&tls_backend_default_singleton, singleton); + g_once_init_leave_pointer (&tls_backend_default_singleton, singleton); } return tls_backend_default_singleton; diff --git a/gio/gtrashportal.c b/gio/gtrashportal.c index 0e1d109f9..82c1356c9 100644 --- a/gio/gtrashportal.c +++ b/gio/gtrashportal.c @@ -48,7 +48,7 @@ ensure_trash_portal (void) { static GXdpTrash *trash = NULL; - if (g_once_init_enter (&trash)) + if (g_once_init_enter_pointer (&trash)) { GDBusConnection *connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL); GXdpTrash *proxy = NULL; @@ -62,7 +62,7 @@ ensure_trash_portal (void) g_object_unref (connection); } - g_once_init_leave (&trash, proxy); + g_once_init_leave_pointer (&trash, proxy); } return trash; diff --git a/gio/gvfs.c b/gio/gvfs.c index f73dcfe89..c741ffebe 100644 --- a/gio/gvfs.c +++ b/gio/gvfs.c @@ -355,7 +355,7 @@ g_vfs_get_default (void) if (GLIB_PRIVATE_CALL (g_check_setuid) ()) return g_vfs_get_local (); - if (g_once_init_enter (&vfs_default_singleton)) + if (g_once_init_enter_pointer (&vfs_default_singleton)) { GVfs *singleton; @@ -363,7 +363,7 @@ g_vfs_get_default (void) "GIO_USE_VFS", (GIOModuleVerifyFunc) g_vfs_is_active); - g_once_init_leave (&vfs_default_singleton, singleton); + g_once_init_leave_pointer (&vfs_default_singleton, singleton); } return vfs_default_singleton; @@ -379,12 +379,12 @@ g_vfs_get_default (void) GVfs * g_vfs_get_local (void) { - static gsize vfs = 0; + static GVfs *vfs = 0; - if (g_once_init_enter (&vfs)) - g_once_init_leave (&vfs, (gsize)_g_local_vfs_new ()); + if (g_once_init_enter_pointer (&vfs)) + g_once_init_leave_pointer (&vfs, _g_local_vfs_new ()); - return G_VFS (vfs); + return vfs; } /** diff --git a/gio/gwin32registrykey.c b/gio/gwin32registrykey.c index df20db102..ed9e854ef 100644 --- a/gio/gwin32registrykey.c +++ b/gio/gwin32registrykey.c @@ -1747,7 +1747,7 @@ static void _g_win32_registry_key_reread (GWin32RegistryKey *key, GWin32RegistryKeyPrivate *buf) { - if (g_once_init_enter (&nt_query_key)) + if (g_once_init_enter_pointer (&nt_query_key)) { NtQueryKeyFunc func; HMODULE ntdll = GetModuleHandleW (L"ntdll.dll"); @@ -1757,7 +1757,7 @@ _g_win32_registry_key_reread (GWin32RegistryKey *key, else func = NULL; - g_once_init_leave (&nt_query_key, func); + g_once_init_leave_pointer (&nt_query_key, func); } /* Assume that predefined keys never get renamed. Also, their handles probably @@ -1875,7 +1875,7 @@ g_win32_registry_get_os_dirs_w (void) { static gunichar2 **mui_os_dirs = NULL; - if (g_once_init_enter (&mui_os_dirs)) + if (g_once_init_enter_pointer (&mui_os_dirs)) { gunichar2 **new_mui_os_dirs; gunichar2 *system32 = NULL; @@ -1915,7 +1915,7 @@ g_win32_registry_get_os_dirs_w (void) new_mui_os_dirs[array_index++] = NULL; - g_once_init_leave (&mui_os_dirs, new_mui_os_dirs); + g_once_init_leave_pointer (&mui_os_dirs, new_mui_os_dirs); } return (const gunichar2 * const *) mui_os_dirs; @@ -1936,7 +1936,7 @@ g_win32_registry_get_os_dirs (void) { static gchar **mui_os_dirs = NULL; - if (g_once_init_enter (&mui_os_dirs)) + if (g_once_init_enter_pointer (&mui_os_dirs)) { gchar **new_mui_os_dirs; gsize array_index; @@ -1960,7 +1960,7 @@ g_win32_registry_get_os_dirs (void) g_critical ("Failed to convert to a system directory #%zu to UTF-8", array_index); } - g_once_init_leave (&mui_os_dirs, new_mui_os_dirs); + g_once_init_leave_pointer (&mui_os_dirs, new_mui_os_dirs); } return (const gchar * const *) mui_os_dirs; @@ -2504,7 +2504,7 @@ g_win32_registry_key_watch (GWin32RegistryKey *key, return FALSE; } - if (g_once_init_enter (&nt_notify_change_multiple_keys)) + if (g_once_init_enter_pointer (&nt_notify_change_multiple_keys)) { NtNotifyChangeMultipleKeysFunc func; HMODULE ntdll = GetModuleHandleW (L"ntdll.dll"); @@ -2514,7 +2514,7 @@ g_win32_registry_key_watch (GWin32RegistryKey *key, else func = NULL; - g_once_init_leave (&nt_notify_change_multiple_keys, func); + g_once_init_leave_pointer (&nt_notify_change_multiple_keys, func); } if (nt_notify_change_multiple_keys== NULL) diff --git a/gio/inotify/inotify-kernel.c b/gio/inotify/inotify-kernel.c index 7733d398e..f950a2174 100644 --- a/gio/inotify/inotify-kernel.c +++ b/gio/inotify/inotify-kernel.c @@ -416,8 +416,8 @@ ik_source_new (gboolean (* callback) (ik_event_t *event)) gboolean _ik_startup (gboolean (*cb)(ik_event_t *event)) { - if (g_once_init_enter (&inotify_source)) - g_once_init_leave (&inotify_source, ik_source_new (cb)); + if (g_once_init_enter_pointer (&inotify_source)) + g_once_init_leave_pointer (&inotify_source, ik_source_new (cb)); return inotify_source->fd >= 0; } diff --git a/glib/gcharset.c b/glib/gcharset.c index 82cd0a7b8..040b499d9 100644 --- a/glib/gcharset.c +++ b/glib/gcharset.c @@ -500,11 +500,11 @@ unalias_lang (char *lang) char *p; int i; - if (g_once_init_enter (&alias_table)) + if (g_once_init_enter_pointer (&alias_table)) { GHashTable *table = g_hash_table_new (g_str_hash, g_str_equal); read_aliases ("/usr/share/locale/locale.alias", table); - g_once_init_leave (&alias_table, table); + g_once_init_leave_pointer (&alias_table, table); } i = 0; diff --git a/glib/gmain.c b/glib/gmain.c index 8400e9726..e990d0a96 100644 --- a/glib/gmain.c +++ b/glib/gmain.c @@ -815,7 +815,7 @@ g_main_context_default (void) { static GMainContext *default_main_context = NULL; - if (g_once_init_enter (&default_main_context)) + if (g_once_init_enter_pointer (&default_main_context)) { GMainContext *context; @@ -828,7 +828,7 @@ g_main_context_default (void) g_print ("global-default main context=%p\n", context); #endif - g_once_init_leave (&default_main_context, context); + g_once_init_leave_pointer (&default_main_context, context); } return default_main_context; diff --git a/glib/gtestutils.c b/glib/gtestutils.c index 483275a0a..8c0f2d0bf 100644 --- a/glib/gtestutils.c +++ b/glib/gtestutils.c @@ -1102,10 +1102,10 @@ g_test_log (GTestLogType lbit, unsigned subtest_level; gdouble timing; - if (g_once_init_enter (&g_default_print_func)) + if (g_once_init_enter_pointer (&g_default_print_func)) { - g_once_init_leave (&g_default_print_func, - g_set_print_handler (g_test_print_handler)); + g_once_init_leave_pointer (&g_default_print_func, + g_set_print_handler (g_test_print_handler)); g_assert_nonnull (g_default_print_func); } diff --git a/glib/gutils.c b/glib/gutils.c index 362c55aff..9949a1e9f 100644 --- a/glib/gutils.c +++ b/glib/gutils.c @@ -663,7 +663,7 @@ g_get_user_database_entry (void) { static UserDatabaseEntry *entry; - if (g_once_init_enter (&entry)) + if (g_once_init_enter_pointer (&entry)) { static UserDatabaseEntry e; @@ -787,7 +787,7 @@ g_get_user_database_entry (void) if (!e.real_name) e.real_name = g_strdup ("Unknown"); - g_once_init_leave (&entry, &e); + g_once_init_leave_pointer (&entry, &e); } return entry; @@ -1065,7 +1065,7 @@ g_get_host_name (void) { static gchar *hostname; - if (g_once_init_enter (&hostname)) + if (g_once_init_enter_pointer (&hostname)) { gboolean failed; gchar *utmp = NULL; @@ -1122,7 +1122,7 @@ g_get_host_name (void) failed = TRUE; #endif - g_once_init_leave (&hostname, failed ? g_strdup ("localhost") : utmp); + g_once_init_leave_pointer (&hostname, failed ? g_strdup ("localhost") : utmp); } return hostname; diff --git a/glib/tests/once.c b/glib/tests/once.c index 0bcaea488..d851ad143 100644 --- a/glib/tests/once.c +++ b/glib/tests/once.c @@ -199,8 +199,8 @@ test_once_init_string (void) g_test_summary ("Test g_once_init_{enter,leave}() usage with a string"); - if (g_once_init_enter (&val)) - g_once_init_leave (&val, "foo"); + if (g_once_init_enter_pointer (&val)) + g_once_init_leave_pointer (&val, "foo"); g_assert_cmpstr (val, ==, "foo"); } diff --git a/glib/tests/onceinit.c b/glib/tests/onceinit.c index 4d10b4fae..1e60b6376 100644 --- a/glib/tests/onceinit.c +++ b/glib/tests/onceinit.c @@ -71,14 +71,14 @@ initializer1 (void) static gpointer initializer2 (void) { - static gsize initialized = 0; - if (g_once_init_enter (&initialized)) + static void *initialized = NULL; + if (g_once_init_enter_pointer (&initialized)) { void *pointer_value = &dummy_value; assert_singleton_execution2 (); - g_once_init_leave (&initialized, (gsize) pointer_value); + g_once_init_leave_pointer (&initialized, pointer_value); } - return (void*) initialized; + return initialized; } static void diff --git a/gobject/gobject.c b/gobject/gobject.c index 871cf6cdb..96aeab22c 100644 --- a/gobject/gobject.c +++ b/gobject/gobject.c @@ -1719,14 +1719,14 @@ maybe_issue_property_deprecation_warning (const GParamSpec *pspec) static GMutex already_warned_lock; gboolean already; - if (g_once_init_enter (&enable_diagnostic)) + if (g_once_init_enter_pointer (&enable_diagnostic)) { const gchar *value = g_getenv ("G_ENABLE_DIAGNOSTIC"); if (!value) value = "0"; - g_once_init_leave (&enable_diagnostic, value); + g_once_init_leave_pointer (&enable_diagnostic, value); } if (enable_diagnostic[0] == '0') diff --git a/gobject/gtype.c b/gobject/gtype.c index 941d8b3aa..371e94cd6 100644 --- a/gobject/gtype.c +++ b/gobject/gtype.c @@ -1867,14 +1867,14 @@ maybe_issue_deprecation_warning (GType type) gboolean already; const char *name; - if (g_once_init_enter (&enable_diagnostic)) + if (g_once_init_enter_pointer (&enable_diagnostic)) { const gchar *value = g_getenv ("G_ENABLE_DIAGNOSTIC"); if (!value) value = "0"; - g_once_init_leave (&enable_diagnostic, value); + g_once_init_leave_pointer (&enable_diagnostic, value); } if (enable_diagnostic[0] == '0')