summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-02-19 23:54:58 +0100
committerLennart Poettering <lennart@poettering.net>2014-02-20 00:03:10 +0100
commit151b9b9662a90455262ce575a8a8ae74bf4ff336 (patch)
tree3e82f3233050d75d23fd69bfdd83aa850727395a /src/network
parent3db729cb8e6822114e9323f4041dcdc080f2fb3c (diff)
api: in constructor function calls, always put the returned object pointer first (or second)
Previously the returned object of constructor functions where sometimes returned as last, sometimes as first and sometimes as second parameter. Let's clean this up a bit. Here are the new rules: 1. The object the new object is derived from is put first, if there is any 2. The object we are creating will be returned in the next arguments 3. This is followed by any additional arguments Rationale: For functions that operate on an object we always put that object first. Constructors should probably not be too different in this regard. Also, if the additional parameters might want to use varargs which suggests to put them last. Note that this new scheme only applies to constructor functions, not to all other functions. We do give a lot of freedom for those. Note that this commit only changes the order of the new functions we added, for old ones we accept the wrong order and leave it like that.
Diffstat (limited to 'src/network')
-rw-r--r--src/network/networkd-address.c8
-rw-r--r--src/network/networkd-link.c16
-rw-r--r--src/network/networkd-manager.c5
-rw-r--r--src/network/networkd-netdev.c6
-rw-r--r--src/network/networkd-route.c4
5 files changed, 20 insertions, 19 deletions
diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c
index 28dcf14c6e..a63773928f 100644
--- a/src/network/networkd-address.c
+++ b/src/network/networkd-address.c
@@ -105,8 +105,8 @@ int address_drop(Address *address, Link *link,
assert(link->manager);
assert(link->manager->rtnl);
- r = sd_rtnl_message_new_addr(link->manager->rtnl, RTM_DELADDR,
- link->ifindex, address->family, &req);
+ r = sd_rtnl_message_new_addr(link->manager->rtnl, &req, RTM_DELADDR,
+ link->ifindex, address->family);
if (r < 0) {
log_error("Could not allocate RTM_DELADDR message: %s",
strerror(-r));
@@ -150,8 +150,8 @@ int address_configure(Address *address, Link *link,
assert(link->manager);
assert(link->manager->rtnl);
- r = sd_rtnl_message_new_addr(link->manager->rtnl, RTM_NEWADDR,
- link->ifindex, address->family, &req);
+ r = sd_rtnl_message_new_addr(link->manager->rtnl, &req, RTM_NEWADDR,
+ link->ifindex, address->family);
if (r < 0) {
log_error("Could not allocate RTM_NEWADDR message: %s",
strerror(-r));
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index e574b2c874..e2d61ae490 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -395,11 +395,11 @@ static int set_hostname(sd_bus *bus, const char *hostname) {
r = sd_bus_message_new_method_call(
bus,
+ &m,
"org.freedesktop.hostname1",
"/org/freedesktop/hostname1",
"org.freedesktop.hostname1",
- "SetHostname",
- &m);
+ "SetHostname");
if (r < 0)
return r;
@@ -446,8 +446,8 @@ static int link_set_mtu(Link *link, uint32_t mtu) {
log_debug_link(link, "setting MTU: %" PRIu32, mtu);
- r = sd_rtnl_message_new_link(link->manager->rtnl, RTM_SETLINK,
- link->ifindex, &req);
+ r = sd_rtnl_message_new_link(link->manager->rtnl, &req,
+ RTM_SETLINK, link->ifindex);
if (r < 0) {
log_error_link(link, "Could not allocate RTM_SETLINK message");
return r;
@@ -813,8 +813,8 @@ static int link_up(Link *link) {
log_debug_link(link, "bringing link up");
- r = sd_rtnl_message_new_link(link->manager->rtnl, RTM_SETLINK,
- link->ifindex, &req);
+ r = sd_rtnl_message_new_link(link->manager->rtnl, &req,
+ RTM_SETLINK, link->ifindex);
if (r < 0) {
log_error_link(link, "Could not allocate RTM_SETLINK message");
return r;
@@ -982,8 +982,8 @@ static int link_getlink(Link *link) {
log_debug_link(link, "requesting link status");
- r = sd_rtnl_message_new_link(link->manager->rtnl, RTM_GETLINK,
- link->ifindex, &req);
+ r = sd_rtnl_message_new_link(link->manager->rtnl, &req,
+ RTM_GETLINK, link->ifindex);
if (r < 0) {
log_error_link(link, "Could not allocate RTM_GETLINK message");
return r;
diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c
index f817d698c4..55e5cafd00 100644
--- a/src/network/networkd-manager.c
+++ b/src/network/networkd-manager.c
@@ -52,7 +52,7 @@ int manager_new(Manager **ret) {
sd_event_set_watchdog(m->event, true);
- r = sd_rtnl_open(RTMGRP_LINK | RTMGRP_IPV4_IFADDR, &m->rtnl);
+ r = sd_rtnl_open(&m->rtnl, RTMGRP_LINK | RTMGRP_IPV4_IFADDR);
if (r < 0)
return r;
@@ -252,9 +252,10 @@ int manager_udev_listen(Manager *m) {
}
r = sd_event_add_io(m->event,
+ &m->udev_event_source,
udev_monitor_get_fd(m->udev_monitor),
EPOLLIN, manager_dispatch_link_udev,
- m, &m->udev_event_source);
+ m);
if (r < 0)
return r;
diff --git a/src/network/networkd-netdev.c b/src/network/networkd-netdev.c
index 01ea8f68bc..ea6da69beb 100644
--- a/src/network/networkd-netdev.c
+++ b/src/network/networkd-netdev.c
@@ -94,8 +94,8 @@ static int netdev_enslave_ready(NetDev *netdev, Link* link, sd_rtnl_message_hand
assert(link);
assert(callback);
- r = sd_rtnl_message_new_link(netdev->manager->rtnl, RTM_SETLINK,
- link->ifindex, &req);
+ r = sd_rtnl_message_new_link(netdev->manager->rtnl, &req,
+ RTM_SETLINK, link->ifindex);
if (r < 0) {
log_error_netdev(netdev,
"Could not allocate RTM_SETLINK message: %s",
@@ -172,7 +172,7 @@ static int netdev_create(NetDev *netdev, Link *link, sd_rtnl_message_handler_t c
assert(netdev->manager);
assert(netdev->manager->rtnl);
- r = sd_rtnl_message_new_link(netdev->manager->rtnl, RTM_NEWLINK, 0, &req);
+ r = sd_rtnl_message_new_link(netdev->manager->rtnl, &req, RTM_NEWLINK, 0);
if (r < 0) {
log_error_netdev(netdev,
"Could not allocate RTM_NEWLINK message: %s",
diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c
index 5896c4a4ac..46a4537196 100644
--- a/src/network/networkd-route.c
+++ b/src/network/networkd-route.c
@@ -105,8 +105,8 @@ int route_configure(Route *route, Link *link,
assert(link->ifindex > 0);
assert(route->family == AF_INET || route->family == AF_INET6);
- r = sd_rtnl_message_new_route(link->manager->rtnl, RTM_NEWROUTE,
- route->family, &req);
+ r = sd_rtnl_message_new_route(link->manager->rtnl, &req,
+ RTM_NEWROUTE, route->family);
if (r < 0) {
log_error("Could not create RTM_NEWROUTE message: %s", strerror(-r));
return r;