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 @@
if (nm_logging_enabled ((level), (domain))) { \
char __prefix[30] = "auth"; \
\
if ((self) != _instance) \
if ((self) != singleton_instance) \
g_snprintf (__prefix, sizeof (__prefix), "auth[%p]", (self)); \
nm_log ((level), (domain), \
"%s: " _NM_UTILS_MACRO_FIRST(__VA_ARGS__), \
......@@ -76,7 +76,7 @@ typedef struct {
#endif
} NMAuthManagerPrivate;
static NMAuthManager *_instance = NULL;
static NMAuthManager *singleton_instance = NULL;
G_DEFINE_TYPE (NMAuthManager, nm_auth_manager, G_TYPE_OBJECT)
......@@ -485,9 +485,9 @@ _dbus_new_proxy_cb (GObject *source_object,
NMAuthManager *
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 *
......@@ -495,14 +495,14 @@ nm_auth_manager_setup (gboolean polkit_enabled)
{
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,
NM_AUTH_MANAGER_POLKIT_ENABLED, polkit_enabled,
NULL);
_LOGD ("set instance");
return (_instance = self);
return (singleton_instance = self);
}
/*****************************************************************************/
......@@ -616,8 +616,8 @@ finalize (GObject *object)
G_OBJECT_CLASS (nm_auth_manager_parent_class)->finalize (object);
if (self == _instance) {
_instance = NULL;
if (self == singleton_instance) {
singleton_instance = NULL;
_LOGD ("unset instance");
}
}
......
......@@ -81,17 +81,17 @@ static void object_destroyed (NMDBusManager *self, gpointer object);
NMDBusManager *
nm_dbus_manager_get (void)
{
static NMDBusManager *singleton = NULL;
static NMDBusManager *singleton_instance = NULL;
static gsize once = 0;
if (g_once_init_enter (&once)) {
singleton = (NMDBusManager *) g_object_new (NM_TYPE_DBUS_MANAGER, NULL);
g_assert (singleton);
if (!nm_dbus_manager_init_bus (singleton))
start_reconnection_timeout (singleton);
singleton_instance = (NMDBusManager *) g_object_new (NM_TYPE_DBUS_MANAGER, NULL);
g_assert (singleton_instance);
if (!nm_dbus_manager_init_bus (singleton_instance))
start_reconnection_timeout (singleton_instance);
g_once_init_leave (&once, 1);
}
return singleton;
return singleton_instance;
}
/**************************************************************/
......
......@@ -50,7 +50,7 @@ typedef struct {
G_DEFINE_TYPE (NMDefaultRouteManager, nm_default_route_manager, G_TYPE_OBJECT)
static NMDefaultRouteManager *_instance;
static NMDefaultRouteManager *singleton_instance;
#define _LOG(level, addr_family, ...) \
G_STMT_START { \
......@@ -61,7 +61,7 @@ static NMDefaultRouteManager *_instance;
char __ch = __addr_family == AF_INET ? '4' : (__addr_family == AF_INET6 ? '6' : '-'); \
char __prefix[30] = "default-route"; \
\
if ((self) != _instance) \
if ((self) != singleton_instance) \
g_snprintf (__prefix, sizeof (__prefix), "default-route%c[%p]", __ch, (self)); \
else \
__prefix[STRLEN ("default-route")] = __ch; \
......@@ -1157,11 +1157,11 @@ static const VTableIP vtable_ip6 = {
NMDefaultRouteManager *
nm_default_route_manager_get ()
{
if (G_UNLIKELY (!_instance)) {
_instance = NM_DEFAULT_ROUTE_MANAGER (g_object_new (NM_TYPE_DEFAULT_ROUTE_MANAGER, NULL));
g_object_add_weak_pointer (G_OBJECT (_instance), (gpointer *) &_instance);
if (G_UNLIKELY (!singleton_instance)) {
singleton_instance = NM_DEFAULT_ROUTE_MANAGER (g_object_new (NM_TYPE_DEFAULT_ROUTE_MANAGER, NULL));
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)
NMInotifyHelper *
nm_inotify_helper_get (void)
{
static NMInotifyHelper *singleton = NULL;
static NMInotifyHelper *singleton_instance = NULL;
if (!singleton) {
singleton = (NMInotifyHelper *) g_object_new (NM_TYPE_INOTIFY_HELPER, NULL);
if (!singleton_instance) {
singleton_instance = (NMInotifyHelper *) g_object_new (NM_TYPE_INOTIFY_HELPER, NULL);
if (!init_inotify (singleton)) {
g_clear_object (&singleton);
if (!init_inotify (singleton_instance)) {
g_clear_object (&singleton_instance);
return NULL;
}
} else
g_object_ref (singleton);
g_object_ref (singleton_instance);
g_assert (singleton);
return singleton;
g_assert (singleton_instance);
return singleton_instance;
}
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