[systemd-devel] [PATCH] sd-bus: the bus returned should be the first arg

Jason A. Donenfeld Jason at zx2c4.com
Tue Feb 18 10:11:08 PST 2014


This matches the API of previous headers, such as sd-journal.h.
---
 TODO                             | 2 --
 src/libsystemd/sd-bus/bus-util.c | 8 ++++----
 src/libsystemd/sd-bus/sd-bus.c   | 4 ++--
 src/machine/machinectl.c         | 2 +-
 src/systemd/sd-bus.h             | 4 ++--
 5 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/TODO b/TODO
index e74aa7e..63f3f7e 100644
--- a/TODO
+++ b/TODO
@@ -29,8 +29,6 @@ Preparation for 209:
 
 * Review new libraries
 
-* libsystemd-journal returns the object created as first param in sd_journal_new(), sd_bus_new() and suchlike as last...
-
 Features:
 
 * implement Distribute= in socket units to allow running multiple
diff --git a/src/libsystemd/sd-bus/bus-util.c b/src/libsystemd/sd-bus/bus-util.c
index a468bca..8a6a70c 100644
--- a/src/libsystemd/sd-bus/bus-util.c
+++ b/src/libsystemd/sd-bus/bus-util.c
@@ -1054,11 +1054,11 @@ int bus_open_transport(BusTransport transport, const char *host, bool user, sd_b
                 break;
 
         case BUS_TRANSPORT_REMOTE:
-                r = sd_bus_open_system_remote(host, bus);
+                r = sd_bus_open_system_remote(bus, host);
                 break;
 
         case BUS_TRANSPORT_CONTAINER:
-                r = sd_bus_open_system_container(host, bus);
+                r = sd_bus_open_system_container(bus, host);
                 break;
 
         default:
@@ -1089,11 +1089,11 @@ int bus_open_transport_systemd(BusTransport transport, const char *host, bool us
                 break;
 
         case BUS_TRANSPORT_REMOTE:
-                r = sd_bus_open_system_remote(host, bus);
+                r = sd_bus_open_system_remote(bus, host);
                 break;
 
         case BUS_TRANSPORT_CONTAINER:
-                r = sd_bus_open_system_container(host, bus);
+                r = sd_bus_open_system_container(bus, host);
                 break;
 
         default:
diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
index 1187690..9b9a2a1 100644
--- a/src/libsystemd/sd-bus/sd-bus.c
+++ b/src/libsystemd/sd-bus/sd-bus.c
@@ -1214,7 +1214,7 @@ fail:
         return r;
 }
 
-_public_ int sd_bus_open_system_remote(const char *host, sd_bus **ret) {
+_public_ int sd_bus_open_system_remote(sd_bus **ret, const char *host) {
         _cleanup_free_ char *e = NULL;
         char *p = NULL;
         sd_bus *bus;
@@ -1250,7 +1250,7 @@ _public_ int sd_bus_open_system_remote(const char *host, sd_bus **ret) {
         return 0;
 }
 
-_public_ int sd_bus_open_system_container(const char *machine, sd_bus **ret) {
+_public_ int sd_bus_open_system_container(sd_bus **ret, const char *machine) {
         _cleanup_free_ char *e = NULL;
         sd_bus *bus;
         char *p;
diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c
index 3f4f8ac..ac2fbe3 100644
--- a/src/machine/machinectl.c
+++ b/src/machine/machinectl.c
@@ -618,7 +618,7 @@ static int login_machine(sd_bus *bus, char **args, unsigned n) {
                 return -EIO;
         }
 
-        r = sd_bus_open_system_container(args[1], &container_bus);
+        r = sd_bus_open_system_container(&container_bus, args[1]);
         if (r < 0) {
                 log_error("Failed to get container bus: %s", strerror(-r));
                 return r;
diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h
index 34d4263..94a435ac 100644
--- a/src/systemd/sd-bus.h
+++ b/src/systemd/sd-bus.h
@@ -102,8 +102,8 @@ int sd_bus_default_system(sd_bus **ret);
 int sd_bus_open(sd_bus **ret);
 int sd_bus_open_user(sd_bus **ret);
 int sd_bus_open_system(sd_bus **ret);
-int sd_bus_open_system_remote(const char *host, sd_bus **ret);
-int sd_bus_open_system_container(const char *machine, sd_bus **ret);
+int sd_bus_open_system_remote(sd_bus **ret, const char *host);
+int sd_bus_open_system_container(sd_bus **ret, const char *machine);
 
 int sd_bus_new(sd_bus **ret);
 int sd_bus_set_address(sd_bus *bus, const char *address);
-- 
1.8.5.4



More information about the systemd-devel mailing list