Commit 822cb293 authored by Thomas Haller's avatar Thomas Haller

core/trivial: rename singleton variables according to default name

parent e725887c
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
if (nm_logging_enabled ((level), (domain))) { \ if (nm_logging_enabled ((level), (domain))) { \
char __prefix[30] = "auth"; \ char __prefix[30] = "auth"; \
\ \
if ((self) != _instance) \ if ((self) != singleton_instance) \
g_snprintf (__prefix, sizeof (__prefix), "auth[%p]", (self)); \ g_snprintf (__prefix, sizeof (__prefix), "auth[%p]", (self)); \
nm_log ((level), (domain), \ nm_log ((level), (domain), \
"%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \ "%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
...@@ -76,7 +76,7 @@ typedef struct { ...@@ -76,7 +76,7 @@ typedef struct {
#endif #endif
} NMAuthManagerPrivate; } NMAuthManagerPrivate;
static NMAuthManager *_instance = NULL; static NMAuthManager *singleton_instance = NULL;
G_DEFINE_TYPE (NMAuthManager, nm_auth_manager, G_TYPE_OBJECT) G_DEFINE_TYPE (NMAuthManager, nm_auth_manager, G_TYPE_OBJECT)
...@@ -485,9 +485,9 @@ _dbus_new_proxy_cb (GObject *source_object, ...@@ -485,9 +485,9 @@ _dbus_new_proxy_cb (GObject *source_object,
NMAuthManager * NMAuthManager *
nm_auth_manager_get () nm_auth_manager_get ()
{ {
g_return_val_if_fail (_instance, NULL); g_return_val_if_fail (singleton_instance, NULL);
return _instance; return singleton_instance;
} }
NMAuthManager * NMAuthManager *
...@@ -495,14 +495,14 @@ nm_auth_manager_setup (gboolean polkit_enabled) ...@@ -495,14 +495,14 @@ nm_auth_manager_setup (gboolean polkit_enabled)
{ {
NMAuthManager *self; NMAuthManager *self;
g_return_val_if_fail (!_instance, _instance); g_return_val_if_fail (!singleton_instance, singleton_instance);
self = g_object_new (NM_TYPE_AUTH_MANAGER, self = g_object_new (NM_TYPE_AUTH_MANAGER,
NM_AUTH_MANAGER_POLKIT_ENABLED, polkit_enabled, NM_AUTH_MANAGER_POLKIT_ENABLED, polkit_enabled,
NULL); NULL);
_LOGD ("set instance"); _LOGD ("set instance");
return (_instance = self); return (singleton_instance = self);
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -616,8 +616,8 @@ finalize (GObject *object) ...@@ -616,8 +616,8 @@ finalize (GObject *object)
G_OBJECT_CLASS (nm_auth_manager_parent_class)->finalize (object); G_OBJECT_CLASS (nm_auth_manager_parent_class)->finalize (object);
if (self == _instance) { if (self == singleton_instance) {
_instance = NULL; singleton_instance = NULL;
_LOGD ("unset instance"); _LOGD ("unset instance");
} }
} }
......
...@@ -81,17 +81,17 @@ static void object_destroyed (NMDBusManager *self, gpointer object); ...@@ -81,17 +81,17 @@ static void object_destroyed (NMDBusManager *self, gpointer object);
NMDBusManager * NMDBusManager *
nm_dbus_manager_get (void) nm_dbus_manager_get (void)
{ {
static NMDBusManager *singleton = NULL; static NMDBusManager *singleton_instance = NULL;
static gsize once = 0; static gsize once = 0;
if (g_once_init_enter (&once)) { if (g_once_init_enter (&once)) {
singleton = (NMDBusManager *) g_object_new (NM_TYPE_DBUS_MANAGER, NULL); singleton_instance = (NMDBusManager *) g_object_new (NM_TYPE_DBUS_MANAGER, NULL);
g_assert (singleton); g_assert (singleton_instance);
if (!nm_dbus_manager_init_bus (singleton)) if (!nm_dbus_manager_init_bus (singleton_instance))
start_reconnection_timeout (singleton); start_reconnection_timeout (singleton_instance);
g_once_init_leave (&once, 1); g_once_init_leave (&once, 1);
} }
return singleton; return singleton_instance;
} }
/**************************************************************/ /**************************************************************/
......
...@@ -50,7 +50,7 @@ typedef struct { ...@@ -50,7 +50,7 @@ typedef struct {
G_DEFINE_TYPE (NMDefaultRouteManager, nm_default_route_manager, G_TYPE_OBJECT) G_DEFINE_TYPE (NMDefaultRouteManager, nm_default_route_manager, G_TYPE_OBJECT)
static NMDefaultRouteManager *_instance; static NMDefaultRouteManager *singleton_instance;
#define _LOG(level, addr_family, ...) \ #define _LOG(level, addr_family, ...) \
G_STMT_START { \ G_STMT_START { \
...@@ -61,7 +61,7 @@ static NMDefaultRouteManager *_instance; ...@@ -61,7 +61,7 @@ static NMDefaultRouteManager *_instance;
char __ch = __addr_family == AF_INET ? '4' : (__addr_family == AF_INET6 ? '6' : '-'); \ char __ch = __addr_family == AF_INET ? '4' : (__addr_family == AF_INET6 ? '6' : '-'); \
char __prefix[30] = "default-route"; \ char __prefix[30] = "default-route"; \
\ \
if ((self) != _instance) \ if ((self) != singleton_instance) \
g_snprintf (__prefix, sizeof (__prefix), "default-route%c[%p]", __ch, (self)); \ g_snprintf (__prefix, sizeof (__prefix), "default-route%c[%p]", __ch, (self)); \
else \ else \
__prefix[STRLEN ("default-route")] = __ch; \ __prefix[STRLEN ("default-route")] = __ch; \
...@@ -1157,11 +1157,11 @@ static const VTableIP vtable_ip6 = { ...@@ -1157,11 +1157,11 @@ static const VTableIP vtable_ip6 = {
NMDefaultRouteManager * NMDefaultRouteManager *
nm_default_route_manager_get () nm_default_route_manager_get ()
{ {
if (G_UNLIKELY (!_instance)) { if (G_UNLIKELY (!singleton_instance)) {
_instance = NM_DEFAULT_ROUTE_MANAGER (g_object_new (NM_TYPE_DEFAULT_ROUTE_MANAGER, NULL)); singleton_instance = NM_DEFAULT_ROUTE_MANAGER (g_object_new (NM_TYPE_DEFAULT_ROUTE_MANAGER, NULL));
g_object_add_weak_pointer (G_OBJECT (_instance), (gpointer *) &_instance); g_object_add_weak_pointer (G_OBJECT (singleton_instance), (gpointer *) &singleton_instance);
} }
return _instance; return singleton_instance;
} }
/***********************************************************************************/ /***********************************************************************************/
......
...@@ -148,20 +148,20 @@ init_inotify (NMInotifyHelper *self) ...@@ -148,20 +148,20 @@ init_inotify (NMInotifyHelper *self)
NMInotifyHelper * NMInotifyHelper *
nm_inotify_helper_get (void) nm_inotify_helper_get (void)
{ {
static NMInotifyHelper *singleton = NULL; static NMInotifyHelper *singleton_instance = NULL;
if (!singleton) { if (!singleton_instance) {
singleton = (NMInotifyHelper *) g_object_new (NM_TYPE_INOTIFY_HELPER, NULL); singleton_instance = (NMInotifyHelper *) g_object_new (NM_TYPE_INOTIFY_HELPER, NULL);
if (!init_inotify (singleton)) { if (!init_inotify (singleton_instance)) {
g_clear_object (&singleton); g_clear_object (&singleton_instance);
return NULL; return NULL;
} }
} else } else
g_object_ref (singleton); g_object_ref (singleton_instance);
g_assert (singleton); g_assert (singleton_instance);
return singleton; return singleton_instance;
} }
static void static void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment