[systemd-devel] [PATCH] sd-rtnl: use correct function convention

Jason A. Donenfeld Jason at zx2c4.com
Wed Feb 19 17:57:48 PST 2014


Ret values come second.
---
 src/libsystemd/sd-rtnl/rtnl-util.c | 4 ++--
 src/libsystemd/sd-rtnl/sd-rtnl.c   | 4 ++--
 src/libsystemd/sd-rtnl/test-rtnl.c | 8 ++++----
 src/nspawn/nspawn.c                | 6 +++---
 src/systemd/sd-rtnl.h              | 4 ++--
 5 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/libsystemd/sd-rtnl/rtnl-util.c b/src/libsystemd/sd-rtnl/rtnl-util.c
index ec1a92e..3bdb4f6 100644
--- a/src/libsystemd/sd-rtnl/rtnl-util.c
+++ b/src/libsystemd/sd-rtnl/rtnl-util.c
@@ -42,7 +42,7 @@ int rtnl_set_link_name(sd_rtnl *rtnl, int ifindex, const char *name) {
         if (r < 0)
                 return r;
 
-        r = sd_rtnl_call(rtnl, message, 0, NULL);
+        r = sd_rtnl_call(rtnl, NULL, message, 0);
         if (r < 0)
                 return r;
 
@@ -91,7 +91,7 @@ int rtnl_set_link_properties(sd_rtnl *rtnl, int ifindex, const char *alias,
         }
 
         if  (need_update) {
-                r = sd_rtnl_call(rtnl, message, 0, NULL);
+                r = sd_rtnl_call(rtnl, NULL, message, 0);
                 if (r < 0)
                         return r;
         }
diff --git a/src/libsystemd/sd-rtnl/sd-rtnl.c b/src/libsystemd/sd-rtnl/sd-rtnl.c
index 0588965..70333fb 100644
--- a/src/libsystemd/sd-rtnl/sd-rtnl.c
+++ b/src/libsystemd/sd-rtnl/sd-rtnl.c
@@ -537,9 +537,9 @@ int sd_rtnl_call_async_cancel(sd_rtnl *nl, uint32_t serial) {
 }
 
 int sd_rtnl_call(sd_rtnl *nl,
+                sd_rtnl_message **ret,
                 sd_rtnl_message *message,
-                uint64_t usec,
-                sd_rtnl_message **ret) {
+                uint64_t usec) {
         usec_t timeout;
         uint32_t serial;
         bool room = false;
diff --git a/src/libsystemd/sd-rtnl/test-rtnl.c b/src/libsystemd/sd-rtnl/test-rtnl.c
index 7bbc448..d965592 100644
--- a/src/libsystemd/sd-rtnl/test-rtnl.c
+++ b/src/libsystemd/sd-rtnl/test-rtnl.c
@@ -41,7 +41,7 @@ static void test_link_configure(sd_rtnl *rtnl, int ifindex) {
         assert(sd_rtnl_message_append_ether_addr(message, IFLA_ADDRESS, ether_aton(mac)) >= 0);
         assert(sd_rtnl_message_append_u32(message, IFLA_MTU, mtu) >= 0);
 
-        assert(sd_rtnl_call(rtnl, message, 0, NULL) == 1);
+        assert(sd_rtnl_call(rtnl, NULL, message, 0) == 1);
 
         assert(sd_rtnl_message_read(message, &type, &data) > 0);
         assert(type == IFLA_IFNAME);
@@ -80,7 +80,7 @@ static void test_link_get(sd_rtnl *rtnl, int ifindex) {
         assert(sd_rtnl_message_append_u32(m, IFLA_NUM_TX_QUEUES, 0) >= 0);
         assert(sd_rtnl_message_append_u32(m, IFLA_NUM_RX_QUEUES, 0) >= 0);
 
-        assert(sd_rtnl_call(rtnl, m, -1, &r) == 1);
+        assert(sd_rtnl_call(rtnl, &r, m, -1) == 1);
 
         /* u8 read back */
         assert(sd_rtnl_message_read(m, &type, &data) == 1);
@@ -372,14 +372,14 @@ int main(void) {
 
         assert(sd_rtnl_message_read(m, &type, &data) == -EPERM);
 
-        assert(sd_rtnl_call(rtnl, m, 0, &r) == 1);
+        assert(sd_rtnl_call(rtnl, &r, m, 0) == 1);
         assert(sd_rtnl_message_get_type(r, &type) >= 0);
         assert(type == RTM_NEWLINK);
 
         assert(sd_rtnl_message_read(m, &type, &data) == 0);
         assert((r = sd_rtnl_message_unref(r)) == NULL);
 
-        assert(sd_rtnl_call(rtnl, m, -1, &r) == -EPERM);
+        assert(sd_rtnl_call(rtnl, &r, m, -1) == -EPERM);
         assert((m = sd_rtnl_message_unref(m)) == NULL);
         assert((r = sd_rtnl_message_unref(r)) == NULL);
 
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index 089af07..beb347f 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -1369,7 +1369,7 @@ static int setup_veth(pid_t pid, char iface_name[]) {
                 return r;
         }
 
-        r = sd_rtnl_call(rtnl, m, 0, NULL);
+        r = sd_rtnl_call(rtnl, NULL, m, 0);
         if (r < 0) {
                 log_error("Failed to add new veth interfaces: %s", strerror(-r));
                 return r;
@@ -1422,7 +1422,7 @@ static int setup_bridge(const char veth_name[]) {
                 return r;
         }
 
-        r = sd_rtnl_call(rtnl, m, 0, NULL);
+        r = sd_rtnl_call(rtnl, NULL, m, 0);
         if (r < 0) {
                 log_error("Failed to add veth interface to bridge: %s", strerror(-r));
                 return r;
@@ -1491,7 +1491,7 @@ static int move_network_interfaces(pid_t pid) {
                         return r;
                 }
 
-                r = sd_rtnl_call(rtnl, m, 0, NULL);
+                r = sd_rtnl_call(rtnl, NULL, m, 0);
                 if (r < 0) {
                         log_error("Failed to move interface %s to namespace: %s", *i, strerror(-r));
                         return r;
diff --git a/src/systemd/sd-rtnl.h b/src/systemd/sd-rtnl.h
index 502183e..edb71d8 100644
--- a/src/systemd/sd-rtnl.h
+++ b/src/systemd/sd-rtnl.h
@@ -50,8 +50,8 @@ int sd_rtnl_call_async(sd_rtnl *nl, sd_rtnl_message *message,
                        sd_rtnl_message_handler_t callback,
                        void *userdata, uint64_t usec, uint32_t *serial);
 int sd_rtnl_call_async_cancel(sd_rtnl *nl, uint32_t serial);
-int sd_rtnl_call(sd_rtnl *nl, sd_rtnl_message *message, uint64_t timeout,
-                 sd_rtnl_message **reply);
+int sd_rtnl_call(sd_rtnl *nl, sd_rtnl_message **reply,
+                       sd_rtnl_message *message, uint64_t timeout);
 
 
 int sd_rtnl_get_events(sd_rtnl *nl);
-- 
1.8.5.4



More information about the systemd-devel mailing list