diff options
author | Thomas Haller <thaller@redhat.com> | 2015-04-18 12:36:09 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-04-21 17:51:34 +0200 |
commit | c6529a9d748ad3c8ee37431d020a7b9223992a23 (patch) | |
tree | add34e4c0dd7718b1d514de717777d663e2e14b6 /src/rdisc | |
parent | ccba1b1e2d1fb2a23dd9e86d8ba44f7a3287cafb (diff) | |
download | NetworkManager-c6529a9d748ad3c8ee37431d020a7b9223992a23.tar.gz |
platform: add self argument to platform functions
Most nm_platform_*() functions operate on the platform
singleton nm_platform_get(). That made sense because the
NMPlatform instance was mainly to hook fake platform for
testing.
While the implicit argument saved some typing, I think explicit is
better. Especially, because NMPlatform could become a more usable
object then just a hook for testing.
With this change, NMPlatform instances can be used individually, not
only as a singleton instance.
Before this change, the constructor of NMLinuxPlatform could not
call any nm_platform_*() functions because the singleton was not
yet initialized. We could only instantiate an incomplete instance,
register it via nm_platform_setup(), and then complete initialization
via singleton->setup().
With this change, we can create and fully initialize NMPlatform instances
before/without setting them up them as singleton.
Also, currently there is no clear distinction between functions
that operate on the NMPlatform instance, and functions that can
be used stand-alone (e.g. nm_platform_ip4_address_to_string()).
The latter can not be mocked for testing. With this change, the
distinction becomes obvious. That is also useful because it becomes
clearer which functions make use of the platform cache and which not.
Inside nm-linux-platform.c, continue the pattern that the
self instance is named @platform. That makes sense because
its type is NMPlatform, and not NMLinuxPlatform what we
would expect from a paramter named @self.
This is a major diff that causes some pain when rebasing. Try
to rebase to the parent commit of this commit as a first step.
Then rebase on top of this commit using merge-strategy "ours".
Diffstat (limited to 'src/rdisc')
-rw-r--r-- | src/rdisc/nm-lndp-rdisc.c | 2 | ||||
-rw-r--r-- | src/rdisc/tests/rdisc.c | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/src/rdisc/nm-lndp-rdisc.c b/src/rdisc/nm-lndp-rdisc.c index 922cb3dd76..a56be09edf 100644 --- a/src/rdisc/nm-lndp-rdisc.c +++ b/src/rdisc/nm-lndp-rdisc.c @@ -57,7 +57,7 @@ G_DEFINE_TYPE (NMLNDPRDisc, nm_lndp_rdisc, NM_TYPE_RDISC) static inline gint32 ipv6_sysctl_get (const char *ifname, const char *property, gint32 defval) { - return nm_platform_sysctl_get_int32 (nm_utils_ip6_property_path (ifname, property), defval); + return nm_platform_sysctl_get_int32 (NM_PLATFORM_GET, nm_utils_ip6_property_path (ifname, property), defval); } NMRDisc * diff --git a/src/rdisc/tests/rdisc.c b/src/rdisc/tests/rdisc.c index d577a63ae4..e05f34f970 100644 --- a/src/rdisc/tests/rdisc.c +++ b/src/rdisc/tests/rdisc.c @@ -60,10 +60,10 @@ main (int argc, char **argv) if (argv[0]) { ifname = argv[0]; - ifindex = nm_platform_link_get_ifindex (ifname); + ifindex = nm_platform_link_get_ifindex (NM_PLATFORM_GET, ifname); } else { ifindex = 1; - ifname = nm_platform_link_get_name (ifindex); + ifname = nm_platform_link_get_name (NM_PLATFORM_GET, ifindex); } rdisc = new (ifindex, ifname); |