summaryrefslogtreecommitdiff
path: root/src/libsystemd
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/libsystemd
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/libsystemd')
-rw-r--r--src/libsystemd/sd-bus/bus-control.c3
-rw-r--r--src/libsystemd/sd-bus/bus-convenience.c8
-rw-r--r--src/libsystemd/sd-bus/bus-creds.c2
-rw-r--r--src/libsystemd/sd-bus/bus-kernel.c4
-rw-r--r--src/libsystemd/sd-bus/bus-message.c28
-rw-r--r--src/libsystemd/sd-bus/bus-objects.c6
-rw-r--r--src/libsystemd/sd-bus/bus-util.c4
-rw-r--r--src/libsystemd/sd-bus/busctl.c2
-rw-r--r--src/libsystemd/sd-bus/sd-bus.c16
-rw-r--r--src/libsystemd/sd-bus/sd-memfd.c8
-rw-r--r--src/libsystemd/sd-bus/test-bus-chat.c28
-rw-r--r--src/libsystemd/sd-bus/test-bus-cleanup.c4
-rw-r--r--src/libsystemd/sd-bus/test-bus-creds.c4
-rw-r--r--src/libsystemd/sd-bus/test-bus-gvariant.c4
-rw-r--r--src/libsystemd/sd-bus/test-bus-kernel-benchmark.c6
-rw-r--r--src/libsystemd/sd-bus/test-bus-kernel.c2
-rw-r--r--src/libsystemd/sd-bus/test-bus-marshal.c4
-rw-r--r--src/libsystemd/sd-bus/test-bus-match.c2
-rw-r--r--src/libsystemd/sd-bus/test-bus-memfd.c4
-rw-r--r--src/libsystemd/sd-bus/test-bus-server.c8
-rw-r--r--src/libsystemd/sd-bus/test-bus-zero-copy.c6
-rw-r--r--src/libsystemd/sd-event/sd-event.c36
-rw-r--r--src/libsystemd/sd-event/test-event.c18
-rw-r--r--src/libsystemd/sd-resolve/sd-resolve.c20
-rw-r--r--src/libsystemd/sd-resolve/test-resolve.c6
-rw-r--r--src/libsystemd/sd-rtnl/rtnl-message.c15
-rw-r--r--src/libsystemd/sd-rtnl/rtnl-util.c4
-rw-r--r--src/libsystemd/sd-rtnl/sd-rtnl.c8
-rw-r--r--src/libsystemd/sd-rtnl/test-rtnl.c33
29 files changed, 146 insertions, 147 deletions
diff --git a/src/libsystemd/sd-bus/bus-control.c b/src/libsystemd/sd-bus/bus-control.c
index b4dbb5b7ee..22b95d589d 100644
--- a/src/libsystemd/sd-bus/bus-control.c
+++ b/src/libsystemd/sd-bus/bus-control.c
@@ -1207,10 +1207,11 @@ _public_ int sd_bus_get_owner_machine_id(sd_bus *bus, const char *name, sd_id128
r = sd_bus_message_new_method_call(
bus,
+ &m,
name,
"/",
"org.freedesktop.DBus.Peer",
- "GetMachineId", &m);
+ "GetMachineId");
if (r < 0)
return r;
diff --git a/src/libsystemd/sd-bus/bus-convenience.c b/src/libsystemd/sd-bus/bus-convenience.c
index 3964960fab..6e02ad365c 100644
--- a/src/libsystemd/sd-bus/bus-convenience.c
+++ b/src/libsystemd/sd-bus/bus-convenience.c
@@ -39,7 +39,7 @@ _public_ int sd_bus_emit_signal(
assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN);
assert_return(!bus_pid_changed(bus), -ECHILD);
- r = sd_bus_message_new_signal(bus, path, interface, member, &m);
+ r = sd_bus_message_new_signal(bus, &m, path, interface, member);
if (r < 0)
return r;
@@ -73,7 +73,7 @@ _public_ int sd_bus_call_method(
assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN);
assert_return(!bus_pid_changed(bus), -ECHILD);
- r = sd_bus_message_new_method_call(bus, destination, path, interface, member, &m);
+ r = sd_bus_message_new_method_call(bus, &m, destination, path, interface, member);
if (r < 0)
return r;
@@ -140,7 +140,7 @@ _public_ int sd_bus_reply_method_error(
if (call->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED)
return 0;
- r = sd_bus_message_new_method_error(call, e, &m);
+ r = sd_bus_message_new_method_error(call, &m, e);
if (r < 0)
return r;
@@ -386,7 +386,7 @@ _public_ int sd_bus_set_property(
assert_return(BUS_IS_OPEN(bus->state), -ENOTCONN);
assert_return(!bus_pid_changed(bus), -ECHILD);
- r = sd_bus_message_new_method_call(bus, destination, path, "org.freedesktop.DBus.Properties", "Set", &m);
+ r = sd_bus_message_new_method_call(bus, &m, destination, path, "org.freedesktop.DBus.Properties", "Set");
if (r < 0)
return r;
diff --git a/src/libsystemd/sd-bus/bus-creds.c b/src/libsystemd/sd-bus/bus-creds.c
index 6143254a60..2d56f3c461 100644
--- a/src/libsystemd/sd-bus/bus-creds.c
+++ b/src/libsystemd/sd-bus/bus-creds.c
@@ -125,7 +125,7 @@ sd_bus_creds* bus_creds_new(void) {
return c;
}
-_public_ int sd_bus_creds_new_from_pid(pid_t pid, uint64_t mask, sd_bus_creds **ret) {
+_public_ int sd_bus_creds_new_from_pid(sd_bus_creds **ret, pid_t pid, uint64_t mask) {
sd_bus_creds *c;
int r;
diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index 8699d30b64..eec62aca9c 100644
--- a/src/libsystemd/sd-bus/bus-kernel.c
+++ b/src/libsystemd/sd-bus/bus-kernel.c
@@ -920,10 +920,10 @@ static int push_name_owner_changed(sd_bus *bus, const char *name, const char *ol
r = sd_bus_message_new_signal(
bus,
+ &m,
"/org/freedesktop/DBus",
"org.freedesktop.DBus",
- "NameOwnerChanged",
- &m);
+ "NameOwnerChanged");
if (r < 0)
return r;
diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c
index fe84f3f0bc..fb894eff1f 100644
--- a/src/libsystemd/sd-bus/bus-message.c
+++ b/src/libsystemd/sd-bus/bus-message.c
@@ -509,10 +509,10 @@ static sd_bus_message *message_new(sd_bus *bus, uint8_t type) {
_public_ int sd_bus_message_new_signal(
sd_bus *bus,
+ sd_bus_message **m,
const char *path,
const char *interface,
- const char *member,
- sd_bus_message **m) {
+ const char *member) {
sd_bus_message *t;
int r;
@@ -549,11 +549,11 @@ fail:
_public_ int sd_bus_message_new_method_call(
sd_bus *bus,
+ sd_bus_message **m,
const char *destination,
const char *path,
const char *interface,
- const char *member,
- sd_bus_message **m) {
+ const char *member) {
sd_bus_message *t;
int r;
@@ -647,8 +647,8 @@ _public_ int sd_bus_message_new_method_return(
_public_ int sd_bus_message_new_method_error(
sd_bus_message *call,
- const sd_bus_error *e,
- sd_bus_message **m) {
+ sd_bus_message **m,
+ const sd_bus_error *e) {
sd_bus_message *t;
int r;
@@ -697,23 +697,23 @@ _public_ int sd_bus_message_new_method_errorf(
bus_error_setfv(&error, name, format, ap);
va_end(ap);
- return sd_bus_message_new_method_error(call, &error, m);
+ return sd_bus_message_new_method_error(call, m, &error);
}
_public_ int sd_bus_message_new_method_errno(
sd_bus_message *call,
+ sd_bus_message **m,
int error,
- const sd_bus_error *p,
- sd_bus_message **m) {
+ const sd_bus_error *p) {
_cleanup_free_ sd_bus_error berror = SD_BUS_ERROR_NULL;
if (sd_bus_error_is_set(p))
- return sd_bus_message_new_method_error(call, p, m);
+ return sd_bus_message_new_method_error(call, m, p);
sd_bus_error_set_errno(&berror, error);
- return sd_bus_message_new_method_error(call, &berror, m);
+ return sd_bus_message_new_method_error(call, m, &berror);
}
_public_ int sd_bus_message_new_method_errnof(
@@ -730,7 +730,7 @@ _public_ int sd_bus_message_new_method_errnof(
bus_error_set_errnofv(&berror, error, format, ap);
va_end(ap);
- return sd_bus_message_new_method_error(call, &berror, m);
+ return sd_bus_message_new_method_error(call, m, &berror);
}
int bus_message_new_synthetic_error(
@@ -5468,14 +5468,14 @@ int bus_message_remarshal(sd_bus *bus, sd_bus_message **m) {
switch ((*m)->header->type) {
case SD_BUS_MESSAGE_SIGNAL:
- r = sd_bus_message_new_signal(bus, (*m)->path, (*m)->interface, (*m)->member, &n);
+ r = sd_bus_message_new_signal(bus, &n, (*m)->path, (*m)->interface, (*m)->member);
if (r < 0)
return r;
break;
case SD_BUS_MESSAGE_METHOD_CALL:
- r = sd_bus_message_new_method_call(bus, (*m)->destination, (*m)->path, (*m)->interface, (*m)->member, &n);
+ r = sd_bus_message_new_method_call(bus, &n, (*m)->destination, (*m)->path, (*m)->interface, (*m)->member);
if (r < 0)
return r;
diff --git a/src/libsystemd/sd-bus/bus-objects.c b/src/libsystemd/sd-bus/bus-objects.c
index b116a5dd10..85800cb348 100644
--- a/src/libsystemd/sd-bus/bus-objects.c
+++ b/src/libsystemd/sd-bus/bus-objects.c
@@ -2004,7 +2004,7 @@ static int emit_properties_changed_on_interface(
if (!n)
return 0;
- r = sd_bus_message_new_signal(bus, path, "org.freedesktop.DBus.Properties", "PropertiesChanged", &m);
+ r = sd_bus_message_new_signal(bus, &m, path, "org.freedesktop.DBus.Properties", "PropertiesChanged");
if (r < 0)
return r;
@@ -2373,7 +2373,7 @@ _public_ int sd_bus_emit_interfaces_added_strv(sd_bus *bus, const char *path, ch
if (m)
m = sd_bus_message_unref(m);
- r = sd_bus_message_new_signal(bus, path, "org.freedesktop.DBus.ObjectManager", "InterfacesAdded", &m);
+ r = sd_bus_message_new_signal(bus, &m, path, "org.freedesktop.DBus.ObjectManager", "InterfacesAdded");
if (r < 0)
return r;
@@ -2441,7 +2441,7 @@ _public_ int sd_bus_emit_interfaces_removed_strv(sd_bus *bus, const char *path,
if (strv_isempty(interfaces))
return 0;
- r = sd_bus_message_new_signal(bus, path, "org.freedesktop.DBus.ObjectManager", "InterfacesRemoved", &m);
+ r = sd_bus_message_new_signal(bus, &m, path, "org.freedesktop.DBus.ObjectManager", "InterfacesRemoved");
if (r < 0)
return r;
diff --git a/src/libsystemd/sd-bus/bus-util.c b/src/libsystemd/sd-bus/bus-util.c
index 8a6a70c60e..2935f69684 100644
--- a/src/libsystemd/sd-bus/bus-util.c
+++ b/src/libsystemd/sd-bus/bus-util.c
@@ -383,11 +383,11 @@ int bus_verify_polkit_async(
r = sd_bus_message_new_method_call(
bus,
+ &pk,
"org.freedesktop.PolicyKit1",
"/org/freedesktop/PolicyKit1/Authority",
"org.freedesktop.PolicyKit1.Authority",
- "CheckAuthorization",
- &pk);
+ "CheckAuthorization");
if (r < 0)
return r;
diff --git a/src/libsystemd/sd-bus/busctl.c b/src/libsystemd/sd-bus/busctl.c
index a59b8eab4f..e326cc047a 100644
--- a/src/libsystemd/sd-bus/busctl.c
+++ b/src/libsystemd/sd-bus/busctl.c
@@ -308,7 +308,7 @@ static int status(sd_bus *bus, char *argv[]) {
if (r < 0)
r = sd_bus_get_owner(bus, argv[1], _SD_BUS_CREDS_ALL, &creds);
else
- r = sd_bus_creds_new_from_pid(pid, _SD_BUS_CREDS_ALL, &creds);
+ r = sd_bus_creds_new_from_pid(&creds, pid, _SD_BUS_CREDS_ALL);
if (r < 0) {
log_error("Failed to get credentials: %s", strerror(-r));
diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
index a97fcf5823..427d53061c 100644
--- a/src/libsystemd/sd-bus/sd-bus.c
+++ b/src/libsystemd/sd-bus/sd-bus.c
@@ -399,11 +399,11 @@ static int bus_send_hello(sd_bus *bus) {
r = sd_bus_message_new_method_call(
bus,
+ &m,
"org.freedesktop.DBus",
"/org/freedesktop/DBus",
"org.freedesktop.DBus",
- "Hello",
- &m);
+ "Hello");
if (r < 0)
return r;
@@ -2384,10 +2384,10 @@ static int process_closing(sd_bus *bus, sd_bus_message **ret) {
/* Then, synthesize a Disconnected message */
r = sd_bus_message_new_signal(
bus,
+ &m,
"/org/freedesktop/DBus/Local",
"org.freedesktop.DBus.Local",
- "Disconnected",
- &m);
+ "Disconnected");
if (r < 0)
return r;
@@ -2821,7 +2821,7 @@ static int attach_io_events(sd_bus *bus) {
return 0;
if (!bus->input_io_event_source) {
- r = sd_event_add_io(bus->event, bus->input_fd, 0, io_callback, bus, &bus->input_io_event_source);
+ r = sd_event_add_io(bus->event, &bus->input_io_event_source, bus->input_fd, 0, io_callback, bus);
if (r < 0)
return r;
@@ -2840,7 +2840,7 @@ static int attach_io_events(sd_bus *bus) {
assert(bus->output_fd >= 0);
if (!bus->output_io_event_source) {
- r = sd_event_add_io(bus->event, bus->output_fd, 0, io_callback, bus, &bus->output_io_event_source);
+ r = sd_event_add_io(bus->event, &bus->output_io_event_source, bus->output_fd, 0, io_callback, bus);
if (r < 0)
return r;
@@ -2889,7 +2889,7 @@ _public_ int sd_bus_attach_event(sd_bus *bus, sd_event *event, int priority) {
bus->event_priority = priority;
- r = sd_event_add_monotonic(bus->event, 0, 0, time_callback, bus, &bus->time_event_source);
+ r = sd_event_add_monotonic(bus->event, &bus->time_event_source, 0, 0, time_callback, bus);
if (r < 0)
goto fail;
@@ -2897,7 +2897,7 @@ _public_ int sd_bus_attach_event(sd_bus *bus, sd_event *event, int priority) {
if (r < 0)
goto fail;
- r = sd_event_add_exit(bus->event, quit_callback, bus, &bus->quit_event_source);
+ r = sd_event_add_exit(bus->event, &bus->quit_event_source, quit_callback, bus);
if (r < 0)
goto fail;
diff --git a/src/libsystemd/sd-bus/sd-memfd.c b/src/libsystemd/sd-bus/sd-memfd.c
index b78ea6a313..7c71476eee 100644
--- a/src/libsystemd/sd-bus/sd-memfd.c
+++ b/src/libsystemd/sd-bus/sd-memfd.c
@@ -36,7 +36,7 @@ struct sd_memfd {
FILE *f;
};
-_public_ int sd_memfd_new(const char *name, sd_memfd **m) {
+_public_ int sd_memfd_new(sd_memfd **m, const char *name) {
struct kdbus_cmd_memfd_make *cmd;
struct kdbus_item *item;
@@ -115,7 +115,7 @@ _public_ int sd_memfd_new(const char *name, sd_memfd **m) {
return 0;
}
-_public_ int sd_memfd_make(int fd, sd_memfd **m) {
+_public_ int sd_memfd_new_from_fd(sd_memfd **m, int fd) {
sd_memfd *n;
uint64_t sz;
@@ -249,11 +249,11 @@ _public_ int sd_memfd_set_size(sd_memfd *m, uint64_t sz) {
return r;
}
-_public_ int sd_memfd_new_and_map(const char *name, sd_memfd **m, size_t sz, void **p) {
+_public_ int sd_memfd_new_and_map(sd_memfd **m, const char *name, size_t sz, void **p) {
sd_memfd *n;
int r;
- r = sd_memfd_new(name, &n);
+ r = sd_memfd_new(&n, name);
if (r < 0)
return r;
diff --git a/src/libsystemd/sd-bus/test-bus-chat.c b/src/libsystemd/sd-bus/test-bus-chat.c
index 021379f0b0..113d15ba97 100644
--- a/src/libsystemd/sd-bus/test-bus-chat.c
+++ b/src/libsystemd/sd-bus/test-bus-chat.c
@@ -340,11 +340,11 @@ finish:
r = sd_bus_message_new_method_call(
bus,
+ &q,
"org.freedesktop.systemd.test",
"/",
"org.freedesktop.systemd.test",
- "ExitClient1",
- &q);
+ "ExitClient1");
if (r < 0)
log_error("Failed to allocate method call: %s", strerror(-r));
else
@@ -386,11 +386,11 @@ static void* client2(void*p) {
r = sd_bus_message_new_method_call(
bus,
+ &m,
"org.freedesktop.systemd.test",
"/foo/bar/waldo/piep",
"org.object.test",
- "Foobar",
- &m);
+ "Foobar");
if (r < 0) {
log_error("Failed to allocate method call: %s", strerror(-r));
goto finish;
@@ -407,10 +407,10 @@ static void* client2(void*p) {
r = sd_bus_message_new_signal(
bus,
+ &m,
"/foobar",
"foo.bar",
- "Notify",
- &m);
+ "Notify");
if (r < 0) {
log_error("Failed to allocate signal: %s", strerror(-r));
goto finish;
@@ -427,11 +427,11 @@ static void* client2(void*p) {
r = sd_bus_message_new_method_call(
bus,
+ &m,
"org.freedesktop.systemd.test",
"/",
"org.freedesktop.DBus.Peer",
- "GetMachineId",
- &m);
+ "GetMachineId");
if (r < 0) {
log_error("Failed to allocate method call: %s", strerror(-r));
goto finish;
@@ -456,11 +456,11 @@ static void* client2(void*p) {
r = sd_bus_message_new_method_call(
bus,
+ &m,
"org.freedesktop.systemd.test",
"/",
"org.freedesktop.systemd.test",
- "Slow",
- &m);
+ "Slow");
if (r < 0) {
log_error("Failed to allocate method call: %s", strerror(-r));
goto finish;
@@ -480,11 +480,11 @@ static void* client2(void*p) {
r = sd_bus_message_new_method_call(
bus,
+ &m,
"org.freedesktop.systemd.test",
"/",
"org.freedesktop.systemd.test",
- "Slow",
- &m);
+ "Slow");
if (r < 0) {
log_error("Failed to allocate method call: %s", strerror(-r));
goto finish;
@@ -519,11 +519,11 @@ finish:
r = sd_bus_message_new_method_call(
bus,
+ &q,
"org.freedesktop.systemd.test",
"/",
"org.freedesktop.systemd.test",
- "ExitClient2",
- &q);
+ "ExitClient2");
if (r < 0) {
log_error("Failed to allocate method call: %s", strerror(-r));
goto finish;
diff --git a/src/libsystemd/sd-bus/test-bus-cleanup.c b/src/libsystemd/sd-bus/test-bus-cleanup.c
index d8ddb8452e..e36a69f0d1 100644
--- a/src/libsystemd/sd-bus/test-bus-cleanup.c
+++ b/src/libsystemd/sd-bus/test-bus-cleanup.c
@@ -47,7 +47,7 @@ static void test_bus_new_method_call(void) {
assert_se(sd_bus_open_system(&bus) >= 0);
- assert_se(sd_bus_message_new_method_call(bus, "a.service.name", "/an/object/path", "an.interface.name", "AMethodName", &m) >= 0);
+ assert_se(sd_bus_message_new_method_call(bus, &m, "a.service.name", "/an/object/path", "an.interface.name", "AMethodName") >= 0);
printf("after message_new_method_call: refcount %u\n", REFCNT_GET(bus->n_ref));
@@ -61,7 +61,7 @@ static void test_bus_new_signal(void) {
assert_se(sd_bus_open_system(&bus) >= 0);
- assert_se(sd_bus_message_new_signal(bus, "/an/object/path", "an.interface.name", "Name", &m) >= 0);
+ assert_se(sd_bus_message_new_signal(bus, &m, "/an/object/path", "an.interface.name", "Name") >= 0);
printf("after message_new_signal: refcount %u\n", REFCNT_GET(bus->n_ref));
diff --git a/src/libsystemd/sd-bus/test-bus-creds.c b/src/libsystemd/sd-bus/test-bus-creds.c
index 966b84c39e..c4894e8696 100644
--- a/src/libsystemd/sd-bus/test-bus-creds.c
+++ b/src/libsystemd/sd-bus/test-bus-creds.c
@@ -28,14 +28,14 @@ int main(int argc, char *argv[]) {
_cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
int r;
- r = sd_bus_creds_new_from_pid(0, _SD_BUS_CREDS_ALL, &creds);
+ r = sd_bus_creds_new_from_pid(&creds, 0, _SD_BUS_CREDS_ALL);
assert_se(r >= 0);
bus_creds_dump(creds, NULL);
creds = sd_bus_creds_unref(creds);
- r = sd_bus_creds_new_from_pid(1, _SD_BUS_CREDS_ALL, &creds);
+ r = sd_bus_creds_new_from_pid(&creds, 1, _SD_BUS_CREDS_ALL);
if (r != -EACCES) {
assert_se(r >= 0);
putchar('\n');
diff --git a/src/libsystemd/sd-bus/test-bus-gvariant.c b/src/libsystemd/sd-bus/test-bus-gvariant.c
index cb07c96273..f2c1fc1257 100644
--- a/src/libsystemd/sd-bus/test-bus-gvariant.c
+++ b/src/libsystemd/sd-bus/test-bus-gvariant.c
@@ -138,7 +138,7 @@ static void test_marshal(void) {
assert_se(sd_bus_open_system(&bus) >= 0);
bus->message_version = 2; /* dirty hack to enable gvariant*/
- assert_se(sd_bus_message_new_method_call(bus, "a.service.name", "/an/object/path/which/is/really/really/long/so/that/we/hit/the/eight/bit/boundary/by/quite/some/margin/to/test/this/stuff/that/it/really/works", "an.interface.name", "AMethodName", &m) >= 0);
+ assert_se(sd_bus_message_new_method_call(bus, &m, "a.service.name", "/an/object/path/which/is/really/really/long/so/that/we/hit/the/eight/bit/boundary/by/quite/some/margin/to/test/this/stuff/that/it/really/works", "an.interface.name", "AMethodName") >= 0);
assert_se(sd_bus_message_append(m,
"a(usv)", 3,
@@ -182,7 +182,7 @@ static void test_marshal(void) {
m = sd_bus_message_unref(m);
- assert_se(sd_bus_message_new_method_call(bus, "a.x", "/a/x", "a.x", "Ax", &m) >= 0);
+ assert_se(sd_bus_message_new_method_call(bus, &m, "a.x", "/a/x", "a.x", "Ax") >= 0);
assert_se(sd_bus_message_append(m, "as", 0) >= 0);
diff --git a/src/libsystemd/sd-bus/test-bus-kernel-benchmark.c b/src/libsystemd/sd-bus/test-bus-kernel-benchmark.c
index 04627d9a77..bfeee59d2f 100644
--- a/src/libsystemd/sd-bus/test-bus-kernel-benchmark.c
+++ b/src/libsystemd/sd-bus/test-bus-kernel-benchmark.c
@@ -77,7 +77,7 @@ static void transaction(sd_bus *b, size_t sz) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL, *reply = NULL;
uint8_t *p;
- assert_se(sd_bus_message_new_method_call(b, ":1.1", "/", "benchmark.server", "Work", &m) >= 0);
+ assert_se(sd_bus_message_new_method_call(b, &m, ":1.1", "/", "benchmark.server", "Work") >= 0);
assert_se(sd_bus_message_append_array_space(m, 'y', sz, (void**) &p) >= 0);
memset(p, 0x80, sz);
@@ -151,7 +151,7 @@ static void client_bisect(const char *address) {
}
b->use_memfd = 1;
- assert_se(sd_bus_message_new_method_call(b, ":1.1", "/", "benchmark.server", "Exit", &x) >= 0);
+ assert_se(sd_bus_message_new_method_call(b, &x, ":1.1", "/", "benchmark.server", "Exit") >= 0);
assert_se(sd_bus_message_append(x, "t", csize) >= 0);
assert_se(sd_bus_send(b, x, NULL) >= 0);
@@ -207,7 +207,7 @@ static void client_chart(const char *address) {
}
b->use_memfd = 1;
- assert_se(sd_bus_message_new_method_call(b, ":1.1", "/", "benchmark.server", "Exit", &x) >= 0);
+ assert_se(sd_bus_message_new_method_call(b, &x, ":1.1", "/", "benchmark.server", "Exit") >= 0);
assert_se(sd_bus_message_append(x, "t", csize) >= 0);
assert_se(sd_bus_send(b, x, NULL) >= 0);
diff --git a/src/libsystemd/sd-bus/test-bus-kernel.c b/src/libsystemd/sd-bus/test-bus-kernel.c
index 30cc313af4..2f0f5aa00b 100644
--- a/src/libsystemd/sd-bus/test-bus-kernel.c
+++ b/src/libsystemd/sd-bus/test-bus-kernel.c
@@ -130,7 +130,7 @@ int main(int argc, char *argv[]) {
r = sd_bus_request_name(a, "net.x0pointer.foobar", 0);
assert_se(r >= 0);
- r = sd_bus_message_new_method_call(b, "net.x0pointer.foobar", "/a/path", "an.inter.face", "AMethod", &m);
+ r = sd_bus_message_new_method_call(b, &m, "net.x0pointer.foobar", "/a/path", "an.inter.face", "AMethod");
assert_se(r >= 0);
assert_se(pipe2(pipe_fds, O_CLOEXEC) >= 0);
diff --git a/src/libsystemd/sd-bus/test-bus-marshal.c b/src/libsystemd/sd-bus/test-bus-marshal.c
index 4fad049ab6..85aaf95d6c 100644
--- a/src/libsystemd/sd-bus/test-bus-marshal.c
+++ b/src/libsystemd/sd-bus/test-bus-marshal.c
@@ -76,7 +76,7 @@ int main(int argc, char *argv[]) {
_cleanup_fclose_ FILE *ms = NULL;
size_t first_size = 0, second_size = 0, third_size = 0;
- r = sd_bus_message_new_method_call(NULL, "foobar.waldo", "/", "foobar.waldo", "Piep", &m);
+ r = sd_bus_message_new_method_call(NULL, &m, "foobar.waldo", "/", "foobar.waldo", "Piep");
assert_se(r >= 0);
r = sd_bus_message_append(m, "s", "a string");
@@ -245,7 +245,7 @@ int main(int argc, char *argv[]) {
r = sd_bus_message_peek_type(m, NULL, NULL);
assert_se(r == 0);
- r = sd_bus_message_new_method_call(NULL, "foobar.waldo", "/", "foobar.waldo", "Piep", &copy);
+ r = sd_bus_message_new_method_call(NULL, &copy, "foobar.waldo", "/", "foobar.waldo", "Piep");
assert_se(r >= 0);
r = sd_bus_message_rewind(m, true);
diff --git a/src/libsystemd/sd-bus/test-bus-match.c b/src/libsystemd/sd-bus/test-bus-match.c
index 7227e2585d..c561be2a65 100644
--- a/src/libsystemd/sd-bus/test-bus-match.c
+++ b/src/libsystemd/sd-bus/test-bus-match.c
@@ -111,7 +111,7 @@ int main(int argc, char *argv[]) {
bus_match_dump(&root, 0);
- assert_se(sd_bus_message_new_signal(NULL, "/foo/bar", "bar.x", "waldo", &m) >= 0);
+ assert_se(sd_bus_message_new_signal(NULL, &m, "/foo/bar", "bar.x", "waldo") >= 0);
assert_se(sd_bus_message_append(m, "ssss", "one", "two", "/prefix/three", "prefix.four") >= 0);
assert_se(bus_message_seal(m, 1, 0) >= 0);
diff --git a/src/libsystemd/sd-bus/test-bus-memfd.c b/src/libsystemd/sd-bus/test-bus-memfd.c
index f0f08ba818..3462732546 100644
--- a/src/libsystemd/sd-bus/test-bus-memfd.c
+++ b/src/libsystemd/sd-bus/test-bus-memfd.c
@@ -40,7 +40,7 @@ int main(int argc, char *argv[]) {
log_set_max_level(LOG_DEBUG);
- r = sd_memfd_new(NULL, &m);
+ r = sd_memfd_new(&m, NULL);
if (r == -ENOENT)
return EXIT_TEST_SKIP;
@@ -103,7 +103,7 @@ int main(int argc, char *argv[]) {
sd_memfd_free(m);
/* new sd_memfd, same underlying memfd */
- r = sd_memfd_make(fd, &m);
+ r = sd_memfd_new_from_fd(&m, fd);
assert_se(r >= 0);
/* we did truncate it to 6 */
diff --git a/src/libsystemd/sd-bus/test-bus-server.c b/src/libsystemd/sd-bus/test-bus-server.c
index 0e65ee782a..96d6298336 100644
--- a/src/libsystemd/sd-bus/test-bus-server.c
+++ b/src/libsystemd/sd-bus/test-bus-server.c
@@ -99,8 +99,8 @@ static void *server(void *p) {
} else if (sd_bus_message_is_method_call(m, NULL, NULL)) {
r = sd_bus_message_new_method_error(
m,
- &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_UNKNOWN_METHOD, "Unknown method."),
- &reply);
+ &reply,
+ &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_UNKNOWN_METHOD, "Unknown method."));
if (r < 0) {
log_error("Failed to allocate return: %s", strerror(-r));
goto fail;
@@ -141,11 +141,11 @@ static int client(struct context *c) {
r = sd_bus_message_new_method_call(
bus,
+ &m,
"org.freedesktop.systemd.test",
"/",
"org.freedesktop.systemd.test",
- "Exit",
- &m);
+ "Exit");
if (r < 0) {
log_error("Failed to allocate method call: %s", strerror(-r));
return r;
diff --git a/src/libsystemd/sd-bus/test-bus-zero-copy.c b/src/libsystemd/sd-bus/test-bus-zero-copy.c
index a2239acaa4..29e40aa0af 100644
--- a/src/libsystemd/sd-bus/test-bus-zero-copy.c
+++ b/src/libsystemd/sd-bus/test-bus-zero-copy.c
@@ -80,7 +80,7 @@ int main(int argc, char *argv[]) {
r = sd_bus_start(b);
assert_se(r >= 0);
- r = sd_bus_message_new_method_call(b, ":1.1", "/a/path", "an.inter.face", "AMethod", &m);
+ r = sd_bus_message_new_method_call(b, &m, ":1.1", "/a/path", "an.inter.face", "AMethod");
assert_se(r >= 0);
r = sd_bus_message_open_container(m, 'r', "aysay");
@@ -93,7 +93,7 @@ int main(int argc, char *argv[]) {
memset(p+1, 'L', FIRST_ARRAY-2);
p[FIRST_ARRAY-1] = '>';
- r = sd_memfd_new_and_map(NULL, &f, STRING_SIZE, (void**) &s);
+ r = sd_memfd_new_and_map(&f, NULL, STRING_SIZE, (void**) &s);
assert_se(r >= 0);
s[0] = '<';
@@ -112,7 +112,7 @@ int main(int argc, char *argv[]) {
sd_memfd_free(f);
- r = sd_memfd_new_and_map(NULL, &f, SECOND_ARRAY, (void**) &p);
+ r = sd_memfd_new_and_map(&f, NULL, SECOND_ARRAY, (void**) &p);
assert_se(r >= 0);
p[0] = '<';
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
index cda92e2604..25dfd17d40 100644
--- a/src/libsystemd/sd-event/sd-event.c
+++ b/src/libsystemd/sd-event/sd-event.c
@@ -599,11 +599,11 @@ static sd_event_source *source_new(sd_event *e, EventSourceType type) {
_public_ int sd_event_add_io(
sd_event *e,
+ sd_event_source **ret,
int fd,
uint32_t events,
sd_event_io_handler_t callback,
- void *userdata,
- sd_event_source **ret) {
+ void *userdata) {
sd_event_source *s;
int r;
@@ -683,6 +683,7 @@ static int event_setup_timer_fd(
static int event_add_time_internal(
sd_event *e,
+ sd_event_source **ret,
EventSourceType type,
int *timer_fd,
clockid_t id,
@@ -691,8 +692,7 @@ static int event_add_time_internal(
uint64_t usec,
uint64_t accuracy,
sd_event_time_handler_t callback,
- void *userdata,
- sd_event_source **ret) {
+ void *userdata) {
sd_event_source *s;
int r;
@@ -755,23 +755,23 @@ fail:
}
_public_ int sd_event_add_monotonic(sd_event *e,
+ sd_event_source **ret,
uint64_t usec,
uint64_t accuracy,
sd_event_time_handler_t callback,
- void *userdata,
- sd_event_source **ret) {
+ void *userdata) {
- return event_add_time_internal(e, SOURCE_MONOTONIC, &e->monotonic_fd, CLOCK_MONOTONIC, &e->monotonic_earliest, &e->monotonic_latest, usec, accuracy, callback, userdata, ret);
+ return event_add_time_internal(e, ret, SOURCE_MONOTONIC, &e->monotonic_fd, CLOCK_MONOTONIC, &e->monotonic_earliest, &e->monotonic_latest, usec, accuracy, callback, userdata);
}
_public_ int sd_event_add_realtime(sd_event *e,
+ sd_event_source **ret,
uint64_t usec,
uint64_t accuracy,
sd_event_time_handler_t callback,
- void *userdata,
- sd_event_source **ret) {
+ void *userdata) {
- return event_add_time_internal(e, SOURCE_REALTIME, &e->realtime_fd, CLOCK_REALTIME, &e->realtime_earliest, &e->monotonic_latest, usec, accuracy, callback, userdata, ret);
+ return event_add_time_internal(e, ret, SOURCE_REALTIME, &e->realtime_fd, CLOCK_REALTIME, &e->realtime_earliest, &e->monotonic_latest, usec, accuracy, callback, userdata);
}
static int event_update_signal_fd(sd_event *e) {
@@ -808,10 +808,10 @@ static int event_update_signal_fd(sd_event *e) {
_public_ int sd_event_add_signal(
sd_event *e,
+ sd_event_source **ret,
int sig,
sd_event_signal_handler_t callback,
- void *userdata,
- sd_event_source **ret) {
+ void *userdata) {
sd_event_source *s;
sigset_t ss;
@@ -865,11 +865,11 @@ _public_ int sd_event_add_signal(
_public_ int sd_event_add_child(
sd_event *e,
+ sd_event_source **ret,
pid_t pid,
int options,
sd_event_child_handler_t callback,
- void *userdata,
- sd_event_source **ret) {
+ void *userdata) {
sd_event_source *s;
int r;
@@ -926,9 +926,9 @@ _public_ int sd_event_add_child(
_public_ int sd_event_add_defer(
sd_event *e,
+ sd_event_source **ret,
sd_event_handler_t callback,
- void *userdata,
- sd_event_source **ret) {
+ void *userdata) {
sd_event_source *s;
int r;
@@ -959,9 +959,9 @@ _public_ int sd_event_add_defer(
_public_ int sd_event_add_exit(
sd_event *e,
+ sd_event_source **ret,
sd_event_handler_t callback,
- void *userdata,
- sd_event_source **ret) {
+ void *userdata) {
sd_event_source *s;
int r;
diff --git a/src/libsystemd/sd-event/test-event.c b/src/libsystemd/sd-event/test-event.c
index c10aa8caa7..0b7e2e48c4 100644
--- a/src/libsystemd/sd-event/test-event.c
+++ b/src/libsystemd/sd-event/test-event.c
@@ -97,7 +97,7 @@ static int signal_handler(sd_event_source *s, const struct signalfd_siginfo *si,
if (pid == 0)
_exit(0);
- assert_se(sd_event_add_child(sd_event_source_get_event(s), pid, WEXITED, child_handler, INT_TO_PTR('f'), &p) >= 0);
+ assert_se(sd_event_add_child(sd_event_source_get_event(s), &p, pid, WEXITED, child_handler, INT_TO_PTR('f')) >= 0);
assert_se(sd_event_source_set_enabled(p, SD_EVENT_ONESHOT) >= 0);
sd_event_source_unref(s);
@@ -118,7 +118,7 @@ static int defer_handler(sd_event_source *s, void *userdata) {
assert_se(sigemptyset(&ss) >= 0);
assert_se(sigaddset(&ss, SIGUSR1) >= 0);
assert_se(sigprocmask(SIG_BLOCK, &ss, NULL) >= 0);
- assert_se(sd_event_add_signal(sd_event_source_get_event(s), SIGUSR1, signal_handler, INT_TO_PTR('e'), &p) >= 0);
+ assert_se(sd_event_add_signal(sd_event_source_get_event(s), &p, SIGUSR1, signal_handler, INT_TO_PTR('e')) >= 0);
assert_se(sd_event_source_set_enabled(p, SD_EVENT_ONESHOT) >= 0);
raise(SIGUSR1);
@@ -137,7 +137,7 @@ static int time_handler(sd_event_source *s, uint64_t usec, void *userdata) {
if (do_quit) {
sd_event_source *p;
- assert_se(sd_event_add_defer(sd_event_source_get_event(s), defer_handler, INT_TO_PTR('d'), &p) >= 0);
+ assert_se(sd_event_add_defer(sd_event_source_get_event(s), &p, defer_handler, INT_TO_PTR('d')) >= 0);
assert_se(sd_event_source_set_enabled(p, SD_EVENT_ONESHOT) >= 0);
} else {
assert(!got_c);
@@ -176,7 +176,7 @@ int main(int argc, char *argv[]) {
/* Test whether we cleanly can destroy an io event source from its own handler */
got_unref = false;
- assert_se(sd_event_add_io(e, k[0], EPOLLIN, unref_handler, NULL, &t) >= 0);
+ assert_se(sd_event_add_io(e, &t, k[0], EPOLLIN, unref_handler, NULL) >= 0);
assert_se(write(k[1], &ch, 1) == 1);
assert_se(sd_event_run(e, (uint64_t) -1) >= 1);
assert_se(got_unref);
@@ -185,7 +185,7 @@ int main(int argc, char *argv[]) {
/* Add a oneshot handler, trigger it, re-enable it, and trigger
* it again. */
- assert_se(sd_event_add_io(e, d[0], EPOLLIN, io_handler, INT_TO_PTR('d'), &w) >= 0);
+ assert_se(sd_event_add_io(e, &w, d[0], EPOLLIN, io_handler, INT_TO_PTR('d')) >= 0);
assert_se(sd_event_source_set_enabled(w, SD_EVENT_ONESHOT) >= 0);
assert_se(write(d[1], &ch, 1) >= 0);
assert_se(sd_event_run(e, (uint64_t) -1) >= 1);
@@ -194,10 +194,10 @@ int main(int argc, char *argv[]) {
assert_se(sd_event_run(e, (uint64_t) -1) >= 1);
assert_se(got_d == 2);
- assert_se(sd_event_add_io(e, a[0], EPOLLIN, io_handler, INT_TO_PTR('a'), &x) >= 0);
- assert_se(sd_event_add_io(e, b[0], EPOLLIN, io_handler, INT_TO_PTR('b'), &y) >= 0);
- assert_se(sd_event_add_monotonic(e, 0, 0, time_handler, INT_TO_PTR('c'), &z) >= 0);
- assert_se(sd_event_add_exit(e, exit_handler, INT_TO_PTR('g'), &q) >= 0);
+ assert_se(sd_event_add_io(e, &x, a[0], EPOLLIN, io_handler, INT_TO_PTR('a')) >= 0);
+ assert_se(sd_event_add_io(e, &y, b[0], EPOLLIN, io_handler, INT_TO_PTR('b')) >= 0);
+ assert_se(sd_event_add_monotonic(e, &z, 0, 0, time_handler, INT_TO_PTR('c')) >= 0);
+ assert_se(sd_event_add_exit(e, &q, exit_handler, INT_TO_PTR('g')) >= 0);
assert_se(sd_event_source_set_priority(x, 99) >= 0);
assert_se(sd_event_source_set_enabled(y, SD_EVENT_ONESHOT) >= 0);
diff --git a/src/libsystemd/sd-resolve/sd-resolve.c b/src/libsystemd/sd-resolve/sd-resolve.c
index 803190f02b..f05fe10b6a 100644
--- a/src/libsystemd/sd-resolve/sd-resolve.c
+++ b/src/libsystemd/sd-resolve/sd-resolve.c
@@ -914,10 +914,10 @@ static int alloc_query(sd_resolve *resolve, sd_resolve_query **_q) {
_public_ int sd_resolve_getaddrinfo(
sd_resolve *resolve,
+ sd_resolve_query **_q,
const char *node,
const char *service,
- const struct addrinfo *hints,
- sd_resolve_query **_q) {
+ const struct addrinfo *hints) {
AddrInfoRequest req = {};
struct msghdr mh = {};
@@ -1007,10 +1007,10 @@ _public_ int sd_resolve_getaddrinfo_done(sd_resolve_query* q, struct addrinfo **
_public_ int sd_resolve_getnameinfo(
sd_resolve *resolve,
+ sd_resolve_query**_q,
const struct sockaddr *sa, socklen_t salen,
int flags,
- int gethost, int getserv,
- sd_resolve_query**_q) {
+ int gethost, int getserv) {
NameInfoRequest req = {};
struct msghdr mh = {};
@@ -1098,10 +1098,10 @@ _public_ int sd_resolve_getnameinfo_done(sd_resolve_query* q, char **ret_host, c
static int resolve_res(
sd_resolve *resolve,
+ sd_resolve_query **_q,
QueryType qtype,
const char *dname,
- int class, int type,
- sd_resolve_query **_q) {
+ int class, int type) {
struct msghdr mh = {};
struct iovec iov[2];
@@ -1141,12 +1141,12 @@ static int resolve_res(
return 0;
}
-_public_ int sd_resolve_res_query(sd_resolve *resolve, const char *dname, int class, int type, sd_resolve_query** q) {
- return resolve_res(resolve, REQUEST_RES_QUERY, dname, class, type, q);
+_public_ int sd_resolve_res_query(sd_resolve *resolve, sd_resolve_query** q, const char *dname, int class, int type) {
+ return resolve_res(resolve, q, REQUEST_RES_QUERY, dname, class, type);
}
-_public_ int sd_resolve_res_search(sd_resolve *resolve, const char *dname, int class, int type, sd_resolve_query** q) {
- return resolve_res(resolve, REQUEST_RES_SEARCH, dname, class, type, q);
+_public_ int sd_resolve_res_search(sd_resolve *resolve, sd_resolve_query** q, const char *dname, int class, int type) {
+ return resolve_res(resolve, q, REQUEST_RES_SEARCH, dname, class, type);
}
_public_ int sd_resolve_res_done(sd_resolve_query* q, unsigned char **answer) {
diff --git a/src/libsystemd/sd-resolve/test-resolve.c b/src/libsystemd/sd-resolve/test-resolve.c
index 2e4981df7f..d3b2d55ec0 100644
--- a/src/libsystemd/sd-resolve/test-resolve.c
+++ b/src/libsystemd/sd-resolve/test-resolve.c
@@ -52,7 +52,7 @@ int main(int argc, char *argv[]) {
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_CANONNAME;
- r = sd_resolve_getaddrinfo(resolve, argc >= 2 ? argv[1] : "www.heise.de", NULL, &hints, &q1);
+ r = sd_resolve_getaddrinfo(resolve, &q1, argc >= 2 ? argv[1] : "www.heise.de", NULL, &hints);
if (r < 0)
log_error("sd_resolve_getaddrinfo(): %s\n", strerror(-r));
@@ -61,12 +61,12 @@ int main(int argc, char *argv[]) {
sa.sin_addr.s_addr = inet_addr(argc >= 3 ? argv[2] : "193.99.144.71");
sa.sin_port = htons(80);
- r = sd_resolve_getnameinfo(resolve, (struct sockaddr*) &sa, sizeof(sa), 0, true, true, &q2);
+ r = sd_resolve_getnameinfo(resolve, &q2, (struct sockaddr*) &sa, sizeof(sa), 0, true, true);
if (r < 0)
log_error("sd_resolve_getnameinfo(): %s\n", strerror(-r));
/* Make a res_query() call */
- r = sd_resolve_res_query(resolve, "_xmpp-client._tcp.gmail.com", C_IN, T_SRV, &q3);
+ r = sd_resolve_res_query(resolve, &q3, "_xmpp-client._tcp.gmail.com", C_IN, T_SRV);
if (r < 0)
log_error("sd_resolve_res_query(): %s\n", strerror(-r));
diff --git a/src/libsystemd/sd-rtnl/rtnl-message.c b/src/libsystemd/sd-rtnl/rtnl-message.c
index 5d4dc71810..8c20b8e765 100644
--- a/src/libsystemd/sd-rtnl/rtnl-message.c
+++ b/src/libsystemd/sd-rtnl/rtnl-message.c
@@ -85,9 +85,8 @@ int sd_rtnl_message_route_set_dst_prefixlen(sd_rtnl_message *m, unsigned char pr
return 0;
}
-int sd_rtnl_message_new_route(sd_rtnl *rtnl, uint16_t nlmsg_type,
- unsigned char rtm_family,
- sd_rtnl_message **ret) {
+int sd_rtnl_message_new_route(sd_rtnl *rtnl, sd_rtnl_message **ret,
+ uint16_t nlmsg_type, unsigned char rtm_family) {
struct rtmsg *rtm;
int r;
@@ -147,8 +146,8 @@ int sd_rtnl_message_link_set_type(sd_rtnl_message *m, unsigned type) {
return 0;
}
-int sd_rtnl_message_new_link(sd_rtnl *rtnl, uint16_t nlmsg_type, int index,
- sd_rtnl_message **ret) {
+int sd_rtnl_message_new_link(sd_rtnl *rtnl, sd_rtnl_message **ret,
+ uint16_t nlmsg_type, int index) {
struct ifinfomsg *ifi;
int r;
@@ -222,9 +221,9 @@ int sd_rtnl_message_addr_set_scope(sd_rtnl_message *m, unsigned char scope) {
return 0;
}
-int sd_rtnl_message_new_addr(sd_rtnl *rtnl, uint16_t nlmsg_type, int index,
- unsigned char family,
- sd_rtnl_message **ret) {
+int sd_rtnl_message_new_addr(sd_rtnl *rtnl, sd_rtnl_message **ret,
+ uint16_t nlmsg_type, int index,
+ unsigned char family) {
struct ifaddrmsg *ifa;
int r;
diff --git a/src/libsystemd/sd-rtnl/rtnl-util.c b/src/libsystemd/sd-rtnl/rtnl-util.c
index ec1a92e01f..fc834e9554 100644
--- a/src/libsystemd/sd-rtnl/rtnl-util.c
+++ b/src/libsystemd/sd-rtnl/rtnl-util.c
@@ -34,7 +34,7 @@ int rtnl_set_link_name(sd_rtnl *rtnl, int ifindex, const char *name) {
assert(ifindex > 0);
assert(name);
- r = sd_rtnl_message_new_link(rtnl, RTM_SETLINK, ifindex, &message);
+ r = sd_rtnl_message_new_link(rtnl, &message, RTM_SETLINK, ifindex);
if (r < 0)
return r;
@@ -61,7 +61,7 @@ int rtnl_set_link_properties(sd_rtnl *rtnl, int ifindex, const char *alias,
if (!alias && !mac && mtu == 0)
return 0;
- r = sd_rtnl_message_new_link(rtnl, RTM_SETLINK, ifindex, &message);
+ r = sd_rtnl_message_new_link(rtnl, &message, RTM_SETLINK, ifindex);
if (r < 0)
return r;
diff --git a/src/libsystemd/sd-rtnl/sd-rtnl.c b/src/libsystemd/sd-rtnl/sd-rtnl.c
index 05889656f9..1b9f583726 100644
--- a/src/libsystemd/sd-rtnl/sd-rtnl.c
+++ b/src/libsystemd/sd-rtnl/sd-rtnl.c
@@ -70,7 +70,7 @@ static bool rtnl_pid_changed(sd_rtnl *rtnl) {
return rtnl->original_pid != getpid();
}
-int sd_rtnl_open(uint32_t groups, sd_rtnl **ret) {
+int sd_rtnl_open(sd_rtnl **ret, uint32_t groups) {
_cleanup_rtnl_unref_ sd_rtnl *rtnl = NULL;
socklen_t addrlen;
int r;
@@ -774,7 +774,7 @@ int sd_rtnl_attach_event(sd_rtnl *rtnl, sd_event *event, int priority) {
return r;
}
- r = sd_event_add_io(rtnl->event, rtnl->fd, 0, io_callback, rtnl, &rtnl->io_event_source);
+ r = sd_event_add_io(rtnl->event, &rtnl->io_event_source, rtnl->fd, 0, io_callback, rtnl);
if (r < 0)
goto fail;
@@ -786,7 +786,7 @@ int sd_rtnl_attach_event(sd_rtnl *rtnl, sd_event *event, int priority) {
if (r < 0)
goto fail;
- r = sd_event_add_monotonic(rtnl->event, 0, 0, time_callback, rtnl, &rtnl->time_event_source);
+ r = sd_event_add_monotonic(rtnl->event, &rtnl->time_event_source, 0, 0, time_callback, rtnl);
if (r < 0)
goto fail;
@@ -794,7 +794,7 @@ int sd_rtnl_attach_event(sd_rtnl *rtnl, sd_event *event, int priority) {
if (r < 0)
goto fail;
- r = sd_event_add_exit(rtnl->event, exit_callback, rtnl, &rtnl->exit_event_source);
+ r = sd_event_add_exit(rtnl->event, &rtnl->exit_event_source, exit_callback, rtnl);
if (r < 0)
goto fail;
diff --git a/src/libsystemd/sd-rtnl/test-rtnl.c b/src/libsystemd/sd-rtnl/test-rtnl.c
index 5ab06d5bad..497cefd4f9 100644
--- a/src/libsystemd/sd-rtnl/test-rtnl.c
+++ b/src/libsystemd/sd-rtnl/test-rtnl.c
@@ -37,7 +37,7 @@ static void test_link_configure(sd_rtnl *rtnl, int ifindex) {
void *data;
/* we'd really like to test NEWLINK, but let's not mess with the running kernel */
- assert(sd_rtnl_message_new_link(rtnl, RTM_GETLINK, ifindex, &message) >= 0);
+ assert(sd_rtnl_message_new_link(rtnl, &message, RTM_GETLINK, ifindex) >= 0);
assert(sd_rtnl_message_append_string(message, IFLA_IFNAME, name) >= 0);
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);
@@ -57,7 +57,6 @@ static void test_link_configure(sd_rtnl *rtnl, int ifindex) {
assert(mtu == *(unsigned int *) data);
}
-
static void test_link_get(sd_rtnl *rtnl, int ifindex) {
sd_rtnl_message *m;
sd_rtnl_message *r;
@@ -66,7 +65,7 @@ static void test_link_get(sd_rtnl *rtnl, int ifindex) {
void *data;
uint16_t type;
- assert(sd_rtnl_message_new_link(rtnl, RTM_GETLINK, ifindex, &m) >= 0);
+ assert(sd_rtnl_message_new_link(rtnl, &m, RTM_GETLINK, ifindex) >= 0);
assert(m);
/* u8 test cases */
@@ -137,7 +136,7 @@ static void test_route(void) {
void *data;
int r;
- r = sd_rtnl_message_new_route(NULL, RTM_NEWROUTE, AF_INET, &req);
+ r = sd_rtnl_message_new_route(NULL, &req, RTM_NEWROUTE, AF_INET);
if (r < 0) {
log_error("Could not create RTM_NEWROUTE message: %s", strerror(-r));
return;
@@ -171,8 +170,8 @@ static void test_route(void) {
static void test_multiple(void) {
sd_rtnl *rtnl1, *rtnl2;
- assert(sd_rtnl_open(0, &rtnl1) >= 0);
- assert(sd_rtnl_open(0, &rtnl2) >= 0);
+ assert(sd_rtnl_open(&rtnl1, 0) >= 0);
+ assert(sd_rtnl_open(&rtnl2, 0) >= 0);
rtnl1 = sd_rtnl_unref(rtnl1);
rtnl2 = sd_rtnl_unref(rtnl2);
@@ -215,8 +214,8 @@ static void test_event_loop(int ifindex) {
ifname = strdup("lo2");
assert(ifname);
- assert(sd_rtnl_open(0, &rtnl) >= 0);
- assert(sd_rtnl_message_new_link(rtnl, RTM_GETLINK, ifindex, &m) >= 0);
+ assert(sd_rtnl_open(&rtnl, 0) >= 0);
+ assert(sd_rtnl_message_new_link(rtnl, &m, RTM_GETLINK, ifindex) >= 0);
assert(sd_rtnl_call_async(rtnl, m, &link_handler, ifname, 0, NULL) >= 0);
@@ -248,9 +247,9 @@ static void test_async(int ifindex) {
ifname = strdup("lo");
assert(ifname);
- assert(sd_rtnl_open(0, &rtnl) >= 0);
+ assert(sd_rtnl_open(&rtnl, 0) >= 0);
- assert(sd_rtnl_message_new_link(rtnl, RTM_GETLINK, ifindex, &m) >= 0);
+ assert(sd_rtnl_message_new_link(rtnl, &m, RTM_GETLINK, ifindex) >= 0);
assert(sd_rtnl_call_async(rtnl, m, &link_handler, ifname, 0, &serial) >= 0);
@@ -263,10 +262,10 @@ static void test_pipe(int ifindex) {
_cleanup_rtnl_message_unref_ sd_rtnl_message *m1 = NULL, *m2 = NULL;
int counter = 0;
- assert(sd_rtnl_open(0, &rtnl) >= 0);
+ assert(sd_rtnl_open(&rtnl, 0) >= 0);
- assert(sd_rtnl_message_new_link(rtnl, RTM_GETLINK, ifindex, &m1) >= 0);
- assert(sd_rtnl_message_new_link(rtnl, RTM_GETLINK, ifindex, &m2) >= 0);
+ assert(sd_rtnl_message_new_link(rtnl, &m1, RTM_GETLINK, ifindex) >= 0);
+ assert(sd_rtnl_message_new_link(rtnl, &m2, RTM_GETLINK, ifindex) >= 0);
counter ++;
assert(sd_rtnl_call_async(rtnl, m1, &pipe_handler, &counter, 0, NULL) >= 0);
@@ -285,7 +284,7 @@ static void test_container(void) {
uint16_t type;
void *data;
- assert(sd_rtnl_message_new_link(NULL, RTM_NEWLINK, 0, &m) >= 0);
+ assert(sd_rtnl_message_new_link(NULL, &m, RTM_NEWLINK, 0) >= 0);
assert(sd_rtnl_message_open_container(m, IFLA_LINKINFO) >= 0);
assert(sd_rtnl_message_open_container(m, IFLA_LINKINFO) == -ENOTSUP);
@@ -325,7 +324,7 @@ static void test_container(void) {
static void test_match(void) {
_cleanup_rtnl_unref_ sd_rtnl *rtnl = NULL;
- assert(sd_rtnl_open(0, &rtnl) >= 0);
+ assert(sd_rtnl_open(&rtnl, 0) >= 0);
assert(sd_rtnl_add_match(rtnl, RTM_NEWLINK, &link_handler, NULL) >= 0);
assert(sd_rtnl_add_match(rtnl, RTM_NEWLINK, &link_handler, NULL) >= 0);
@@ -351,7 +350,7 @@ int main(void) {
test_container();
- assert(sd_rtnl_open(0, &rtnl) >= 0);
+ assert(sd_rtnl_open(&rtnl, 0) >= 0);
assert(rtnl);
if_loopback = (int) if_nametoindex("lo");
@@ -365,7 +364,7 @@ int main(void) {
test_link_configure(rtnl, if_loopback);
- assert(sd_rtnl_message_new_link(rtnl, RTM_GETLINK, if_loopback, &m) >= 0);
+ assert(sd_rtnl_message_new_link(rtnl, &m, RTM_GETLINK, if_loopback) >= 0);
assert(m);
assert(sd_rtnl_message_get_type(m, &type) >= 0);