mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-08 23:10:29 +01:00
platform: drop virtual setup() initalization function
We already have nm_*_platform_setup() that gets specified via -DSETUP. This SETUP() hook gives us all the flexiblity we need to customize our singleton, so just do any required setup there. Also, it would be easier to add an alternative (hypotetical) nm_fake_platform_setup_custom() to customize the singleton then to parametrize the NMPlatform:setup() implementation. So this virtual function is less flexible and redundant.
This commit is contained in:
parent
a50d77d952
commit
fe2608c903
3 changed files with 8 additions and 25 deletions
|
|
@ -60,14 +60,6 @@ G_DEFINE_TYPE (NMFakePlatform, nm_fake_platform, NM_TYPE_PLATFORM)
|
|||
|
||||
/******************************************************************/
|
||||
|
||||
void
|
||||
nm_fake_platform_setup (void)
|
||||
{
|
||||
nm_platform_setup (g_object_new (NM_TYPE_FAKE_PLATFORM, NULL));
|
||||
}
|
||||
|
||||
/******************************************************************/
|
||||
|
||||
static gboolean
|
||||
sysctl_set (NMPlatform *platform, const char *path, const char *value)
|
||||
{
|
||||
|
|
@ -1336,9 +1328,15 @@ nm_fake_platform_init (NMFakePlatform *fake_platform)
|
|||
priv->ip6_routes = g_array_new (TRUE, TRUE, sizeof (NMPlatformIP6Route));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
setup (NMPlatform *platform)
|
||||
void
|
||||
nm_fake_platform_setup (void)
|
||||
{
|
||||
NMPlatform *platform;
|
||||
|
||||
platform = g_object_new (NM_TYPE_FAKE_PLATFORM, NULL);
|
||||
|
||||
nm_platform_setup (platform);
|
||||
|
||||
/* skip zero element */
|
||||
link_add (platform, NULL, NM_LINK_TYPE_NONE, NULL, 0);
|
||||
|
||||
|
|
@ -1349,8 +1347,6 @@ setup (NMPlatform *platform)
|
|||
link_add (platform, "eth0", NM_LINK_TYPE_ETHERNET, NULL, 0);
|
||||
link_add (platform, "eth1", NM_LINK_TYPE_ETHERNET, NULL, 0);
|
||||
link_add (platform, "eth2", NM_LINK_TYPE_ETHERNET, NULL, 0);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1386,8 +1382,6 @@ nm_fake_platform_class_init (NMFakePlatformClass *klass)
|
|||
/* virtual methods */
|
||||
object_class->finalize = nm_fake_platform_finalize;
|
||||
|
||||
platform_class->setup = setup;
|
||||
|
||||
platform_class->sysctl_set = sysctl_set;
|
||||
platform_class->sysctl_get = sysctl_get;
|
||||
|
||||
|
|
|
|||
|
|
@ -96,19 +96,10 @@ static NMPlatform *singleton_instance = NULL;
|
|||
void
|
||||
nm_platform_setup (NMPlatform *instance)
|
||||
{
|
||||
NMPlatformClass *klass;
|
||||
|
||||
g_return_if_fail (NM_IS_PLATFORM (instance));
|
||||
g_return_if_fail (!singleton_instance);
|
||||
|
||||
singleton_instance = instance;
|
||||
|
||||
klass = NM_PLATFORM_GET_CLASS (singleton_instance);
|
||||
|
||||
if (klass->setup) {
|
||||
if (!klass->setup (singleton_instance))
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -357,8 +357,6 @@ struct _NMPlatform {
|
|||
typedef struct {
|
||||
GObjectClass parent;
|
||||
|
||||
gboolean (*setup) (NMPlatform *);
|
||||
|
||||
gboolean (*sysctl_set) (NMPlatform *, const char *path, const char *value);
|
||||
char * (*sysctl_get) (NMPlatform *, const char *path);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue