diff options
author | Dan Winship <danw@gnome.org> | 2010-01-03 14:47:56 -0500 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2012-05-15 13:46:38 -0400 |
commit | e011d2c92162d25a6e6d5f67d462edfeb4af3d7a (patch) | |
tree | c86d4101df01a2ace2b89597d5431fcfb78eed78 /gio | |
parent | 2a4235d0f3fe3b3fb007385ee59082c0987158ce (diff) | |
download | glib-e011d2c92162d25a6e6d5f67d462edfeb4af3d7a.tar.gz glib-e011d2c92162d25a6e6d5f67d462edfeb4af3d7a.tar.bz2 glib-e011d2c92162d25a6e6d5f67d462edfeb4af3d7a.zip |
Add g_type_ensure() and use it rather than playing games with volatile
https://bugzilla.gnome.org/show_bug.cgi?id=605976
Diffstat (limited to 'gio')
-rw-r--r-- | gio/gicon.c | 10 | ||||
-rw-r--r-- | gio/ginetaddress.c | 4 | ||||
-rw-r--r-- | gio/giomodule.c | 38 | ||||
-rw-r--r-- | gio/gresolver.c | 5 | ||||
-rw-r--r-- | gio/gsocket.c | 4 | ||||
-rw-r--r-- | gio/gsocketconnection.c | 6 | ||||
-rw-r--r-- | gio/gsocketcontrolmessage.c | 8 | ||||
-rw-r--r-- | gio/gunixconnection.c | 5 |
8 files changed, 31 insertions, 49 deletions
diff --git a/gio/gicon.c b/gio/gicon.c index abc9a8d2f..df44bb021 100644 --- a/gio/gicon.c +++ b/gio/gicon.c @@ -375,12 +375,10 @@ g_icon_new_from_tokens (char **tokens, static void ensure_builtin_icon_types (void) { - static volatile GType t; - t = g_themed_icon_get_type (); - t = g_file_icon_get_type (); - t = g_emblemed_icon_get_type (); - t = g_emblem_get_type (); - (t); /* To avoid -Wunused-but-set-variable */ + g_type_ensure (G_TYPE_THEMED_ICON); + g_type_ensure (G_TYPE_FILE_ICON); + g_type_ensure (G_TYPE_EMBLEMED_ICON); + g_type_ensure (G_TYPE_EMBLEM); } /** diff --git a/gio/ginetaddress.c b/gio/ginetaddress.c index 7de45e75d..0b1a1ad50 100644 --- a/gio/ginetaddress.c +++ b/gio/ginetaddress.c @@ -401,7 +401,6 @@ g_inet_address_init (GInetAddress *address) GInetAddress * g_inet_address_new_from_string (const gchar *string) { - volatile GType type; #ifdef G_OS_WIN32 struct sockaddr_storage sa; struct sockaddr_in *sin = (struct sockaddr_in *)&sa; @@ -413,8 +412,7 @@ g_inet_address_new_from_string (const gchar *string) #endif /* Make sure _g_networking_init() has been called */ - type = g_inet_address_get_type (); - (type); /* To avoid -Wunused-but-set-variable */ + g_type_ensure (G_TYPE_INET_ADDRESS); #ifdef G_OS_WIN32 memset (&sa, 0, sizeof (sa)); diff --git a/gio/giomodule.c b/gio/giomodule.c index d8ce13815..37a9e70a9 100644 --- a/gio/giomodule.c +++ b/gio/giomodule.c @@ -909,39 +909,39 @@ _g_io_modules_ensure_loaded (void) g_io_module_scope_free (scope); /* Initialize types from built-in "modules" */ - g_null_settings_backend_get_type (); - g_memory_settings_backend_get_type (); + g_type_ensure (g_null_settings_backend_get_type ()); + g_type_ensure (g_memory_settings_backend_get_type ()); #if defined(HAVE_SYS_INOTIFY_H) || defined(HAVE_LINUX_INOTIFY_H) - _g_inotify_directory_monitor_get_type (); - _g_inotify_file_monitor_get_type (); + g_type_ensure (_g_inotify_directory_monitor_get_type ()); + g_type_ensure (_g_inotify_file_monitor_get_type ()); #endif #if defined(HAVE_FEN) - _g_fen_directory_monitor_get_type (); - _g_fen_file_monitor_get_type (); + g_type_ensure (_g_fen_directory_monitor_get_type ()); + g_type_ensure (_g_fen_file_monitor_get_type ()); #endif #ifdef G_OS_WIN32 - _g_win32_volume_monitor_get_type (); - g_win32_directory_monitor_get_type (); - g_registry_backend_get_type (); + g_type_ensure (_g_win32_volume_monitor_get_type ()); + g_type_ensure (g_win32_directory_monitor_get_type ()); + g_type_ensure (g_registry_backend_get_type ()); #endif #ifdef HAVE_CARBON g_nextstep_settings_backend_get_type (); #endif #ifdef G_OS_UNIX - _g_unix_volume_monitor_get_type (); + g_type_ensure (_g_unix_volume_monitor_get_type ()); #endif #ifdef G_OS_WIN32 - _g_winhttp_vfs_get_type (); + g_type_ensure (_g_winhttp_vfs_get_type ()); #endif - _g_local_vfs_get_type (); - _g_dummy_proxy_resolver_get_type (); - _g_socks4a_proxy_get_type (); - _g_socks4_proxy_get_type (); - _g_socks5_proxy_get_type (); - _g_dummy_tls_backend_get_type (); - g_network_monitor_base_get_type (); + g_type_ensure (_g_local_vfs_get_type ()); + g_type_ensure (_g_dummy_proxy_resolver_get_type ()); + g_type_ensure (_g_socks4a_proxy_get_type ()); + g_type_ensure (_g_socks4_proxy_get_type ()); + g_type_ensure (_g_socks5_proxy_get_type ()); + g_type_ensure (_g_dummy_tls_backend_get_type ()); + g_type_ensure (g_network_monitor_base_get_type ()); #ifdef HAVE_NETLINK - _g_network_monitor_netlink_get_type (); + g_type_ensure (_g_network_monitor_netlink_get_type ()); #endif } diff --git a/gio/gresolver.c b/gio/gresolver.c index 9f80fc0fc..811c971ee 100644 --- a/gio/gresolver.c +++ b/gio/gresolver.c @@ -146,8 +146,6 @@ g_resolver_real_lookup_service_finish (GResolver *resolver, static void g_resolver_class_init (GResolverClass *resolver_class) { - volatile GType type; - /* Automatically pass these over to the lookup_records methods */ resolver_class->lookup_service = g_resolver_real_lookup_service; resolver_class->lookup_service_async = g_resolver_real_lookup_service_async; @@ -156,8 +154,7 @@ g_resolver_class_init (GResolverClass *resolver_class) g_type_class_add_private (resolver_class, sizeof (GResolverPrivate)); /* Make sure _g_networking_init() has been called */ - type = g_inet_address_get_type (); - (type); /* To avoid -Wunused-but-set-variable */ + g_type_ensure (G_TYPE_INET_ADDRESS); /* Initialize _g_resolver_addrinfo_hints */ #ifdef AI_ADDRCONFIG diff --git a/gio/gsocket.c b/gio/gsocket.c index 0b8d91bf2..9062cc962 100644 --- a/gio/gsocket.c +++ b/gio/gsocket.c @@ -742,11 +742,9 @@ static void g_socket_class_init (GSocketClass *klass) { GObjectClass *gobject_class G_GNUC_UNUSED = G_OBJECT_CLASS (klass); - volatile GType type; /* Make sure winsock has been initialized */ - type = g_inet_address_get_type (); - (type); /* To avoid -Wunused-but-set-variable */ + g_type_ensure (G_TYPE_INET_ADDRESS); #ifdef SIGPIPE /* There is no portable, thread-safe way to avoid having the process diff --git a/gio/gsocketconnection.c b/gio/gsocketconnection.c index ee391ab18..a881a4723 100644 --- a/gio/gsocketconnection.c +++ b/gio/gsocketconnection.c @@ -602,12 +602,10 @@ g_socket_connection_factory_register_type (GType g_type, static void init_builtin_types (void) { - volatile GType a_type; #ifndef G_OS_WIN32 - a_type = g_unix_connection_get_type (); + g_type_ensure (G_TYPE_UNIX_CONNECTION); #endif - a_type = g_tcp_connection_get_type (); - (a_type); /* To avoid -Wunused-but-set-variable */ + g_type_ensure (G_TYPE_TCP_CONNECTION); } /** diff --git a/gio/gsocketcontrolmessage.c b/gio/gsocketcontrolmessage.c index 6b1ad8df8..4cd3ed8e8 100644 --- a/gio/gsocketcontrolmessage.c +++ b/gio/gsocketcontrolmessage.c @@ -177,15 +177,11 @@ g_socket_control_message_deserialize (int level, GType *message_types; guint n_message_types; int i; -#ifndef G_OS_WIN32 - volatile GType a_type; -#endif /* Ensure we know about the built in types */ #ifndef G_OS_WIN32 - a_type = g_unix_credentials_message_get_type (); - a_type = g_unix_fd_message_get_type (); - (a_type); /* To avoid -Wunused-but-set-variable */ + g_type_ensure (G_TYPE_UNIX_CREDENTIALS_MESSAGE); + g_type_ensure (G_TYPE_UNIX_FD_MESSAGE); #endif message_types = g_type_children (G_TYPE_SOCKET_CONTROL_MESSAGE, &n_message_types); diff --git a/gio/gunixconnection.c b/gio/gunixconnection.c index 70a31a4e5..b0ac143d9 100644 --- a/gio/gunixconnection.c +++ b/gio/gunixconnection.c @@ -473,7 +473,6 @@ g_unix_connection_receive_credentials (GUnixConnection *connection, gint nscm; GSocket *socket; gint n; - volatile GType credentials_message_gtype; gssize num_bytes_read; #ifdef __linux__ gboolean turn_off_so_passcreds; @@ -543,9 +542,7 @@ g_unix_connection_receive_credentials (GUnixConnection *connection, } #endif - /* ensure the type of GUnixCredentialsMessage has been registered with the type system */ - credentials_message_gtype = G_TYPE_UNIX_CREDENTIALS_MESSAGE; - (credentials_message_gtype); /* To avoid -Wunused-but-set-variable */ + g_type_ensure (G_TYPE_UNIX_CREDENTIALS_MESSAGE); num_bytes_read = g_socket_receive_message (socket, NULL, /* GSocketAddress **address */ NULL, |