diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-02-19 23:54:58 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-02-20 00:03:10 +0100 |
commit | 151b9b9662a90455262ce575a8a8ae74bf4ff336 (patch) | |
tree | 3e82f3233050d75d23fd69bfdd83aa850727395a | |
parent | 3db729cb8e6822114e9323f4041dcdc080f2fb3c (diff) | |
download | systemd-151b9b9662a90455262ce575a8a8ae74bf4ff336.tar.gz |
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.
81 files changed, 326 insertions, 318 deletions
diff --git a/src/bus-driverd/bus-driverd.c b/src/bus-driverd/bus-driverd.c index 7df4b4c9b1..54059604b1 100644 --- a/src/bus-driverd/bus-driverd.c +++ b/src/bus-driverd/bus-driverd.c @@ -776,11 +776,11 @@ static int driver_update_environment(sd_bus*bus, sd_bus_message *m, void *userda r = sd_bus_message_new_method_call( bus, + &msg, "org.freedesktop.systemd1", "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", - "SetEnvironment", - &msg); + "SetEnvironment"); if (r < 0) return r; diff --git a/src/bus-proxyd/bus-proxyd.c b/src/bus-proxyd/bus-proxyd.c index 5869d79c52..b9e4d9d2ac 100644 --- a/src/bus-proxyd/bus-proxyd.c +++ b/src/bus-proxyd/bus-proxyd.c @@ -216,19 +216,19 @@ static int synthesize_name_acquired(sd_bus *a, sd_bus *b, sd_bus_message *m) { r = sd_bus_message_new_signal( b, + &n, "/org/freedesktop/DBus", "org.freedesktop.DBus", - "NameLost", - &n); + "NameLost"); } else if (streq(new_owner, a->unique_name)) { r = sd_bus_message_new_signal( b, + &n, "/org/freedesktop/DBus", "org.freedesktop.DBus", - "NameAcquired", - &n); + "NameAcquired"); } else return 0; @@ -359,10 +359,10 @@ static int process_hello(sd_bus *a, sd_bus *b, sd_bus_message *m, bool *got_hell n = sd_bus_message_unref(n); r = sd_bus_message_new_signal( b, + &n, "/org/freedesktop/DBus", "org.freedesktop.DBus", - "NameAcquired", - &n); + "NameAcquired"); if (r < 0) { log_error("Failed to allocate initial NameAcquired message: %s", strerror(-r)); return r; diff --git a/src/core/automount.c b/src/core/automount.c index f500850f83..889b20e25d 100644 --- a/src/core/automount.c +++ b/src/core/automount.c @@ -256,7 +256,7 @@ static int automount_coldplug(Unit *u) { assert(a->pipe_fd >= 0); - r = sd_event_add_io(u->manager->event, a->pipe_fd, EPOLLIN, automount_dispatch_io, u, &a->pipe_event_source); + r = sd_event_add_io(u->manager->event, &a->pipe_event_source, a->pipe_fd, EPOLLIN, automount_dispatch_io, u); if (r < 0) return r; } @@ -531,7 +531,7 @@ static void automount_enter_waiting(Automount *a) { close_nointr_nofail(ioctl_fd); ioctl_fd = -1; - r = sd_event_add_io(UNIT(a)->manager->event, p[0], EPOLLIN, automount_dispatch_io, a, &a->pipe_event_source); + r = sd_event_add_io(UNIT(a)->manager->event, &a->pipe_event_source, p[0], EPOLLIN, automount_dispatch_io, a); if (r < 0) goto fail; diff --git a/src/core/busname.c b/src/core/busname.c index 0d19311db1..4c34538c65 100644 --- a/src/core/busname.c +++ b/src/core/busname.c @@ -217,7 +217,7 @@ static int busname_watch_fd(BusName *n) { if (n->event_source) r = sd_event_source_set_enabled(n->event_source, SD_EVENT_ON); else - r = sd_event_add_io(UNIT(n)->manager->event, n->starter_fd, EPOLLIN, busname_dispatch_io, n, &n->event_source); + r = sd_event_add_io(UNIT(n)->manager->event, &n->event_source, n->starter_fd, EPOLLIN, busname_dispatch_io, n); if (r < 0) { log_warning_unit(UNIT(n)->id, "Failed to watch starter fd: %s", strerror(-r)); busname_unwatch_fd(n); diff --git a/src/core/dbus-job.c b/src/core/dbus-job.c index 6489348fb2..a8eae4734e 100644 --- a/src/core/dbus-job.c +++ b/src/core/dbus-job.c @@ -137,10 +137,10 @@ static int send_new_signal(sd_bus *bus, const char *destination, Job *j) { r = sd_bus_message_new_signal( bus, + &m, "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", - "JobNew", - &m); + "JobNew"); if (r < 0) return r; @@ -196,10 +196,10 @@ static int send_removed_signal(sd_bus *bus, const char *destination, Job *j) { r = sd_bus_message_new_signal( bus, + &m, "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", - "JobRemoved", - &m); + "JobRemoved"); if (r < 0) return r; diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c index a9b8fad25c..75004cb7c4 100644 --- a/src/core/dbus-manager.c +++ b/src/core/dbus-manager.c @@ -1338,7 +1338,7 @@ static int send_unit_files_changed(sd_bus *bus, const char *destination, void *u assert(bus); - r = sd_bus_message_new_signal(bus, "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", "UnitFilesChanged", &message); + r = sd_bus_message_new_signal(bus, &message, "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", "UnitFilesChanged"); if (r < 0) return r; @@ -1680,7 +1680,7 @@ static int send_finished(sd_bus *bus, const char *destination, void *userdata) { assert(bus); assert(times); - r = sd_bus_message_new_signal(bus, "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", "StartupFinished", &message); + r = sd_bus_message_new_signal(bus, &message, "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", "StartupFinished"); if (r < 0) return r; @@ -1716,7 +1716,7 @@ static int send_reloading(sd_bus *bus, const char *destination, void *userdata) assert(bus); - r = sd_bus_message_new_signal(bus, "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", "Reloading", &message); + r = sd_bus_message_new_signal(bus, &message, "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", "Reloading"); if (r < 0) return r; diff --git a/src/core/dbus-scope.c b/src/core/dbus-scope.c index 73b7bbf18c..b9e3be483b 100644 --- a/src/core/dbus-scope.c +++ b/src/core/dbus-scope.c @@ -209,10 +209,10 @@ int bus_scope_send_request_stop(Scope *s) { r = sd_bus_message_new_signal( UNIT(s)->manager->api_bus, + &m, p, "org.freedesktop.systemd1.Scope", - "RequestStop", - &m); + "RequestStop"); if (r < 0) return r; diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c index 8156fda82a..24d8a598e7 100644 --- a/src/core/dbus-unit.c +++ b/src/core/dbus-unit.c @@ -604,10 +604,10 @@ static int send_new_signal(sd_bus *bus, const char *destination, void *userdata) r = sd_bus_message_new_signal( bus, + &m, "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", - "UnitNew", - &m); + "UnitNew"); if (r < 0) return r; @@ -689,10 +689,10 @@ static int send_removed_signal(sd_bus *bus, const char *destination, void *userd r = sd_bus_message_new_signal( bus, + &m, "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", - "UnitRemoved", - &m); + "UnitRemoved"); if (r < 0) return r; diff --git a/src/core/dbus.c b/src/core/dbus.c index 4111a14ee0..1059415711 100644 --- a/src/core/dbus.c +++ b/src/core/dbus.c @@ -190,7 +190,7 @@ failed: log_debug("D-Bus activation failed for %s: %s", name, bus_error_message(&error, r)); - r = sd_bus_message_new_signal(bus, "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Activator", "ActivationFailure", &reply); + r = sd_bus_message_new_signal(bus, &reply, "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Activator", "ActivationFailure"); if (r < 0) { bus_log_create_error(r); return 0; @@ -994,7 +994,7 @@ static int bus_init_private(Manager *m) { return -errno; } - r = sd_event_add_io(m->event, fd, EPOLLIN, bus_on_connection, m, &s); + r = sd_event_add_io(m->event, &s, fd, EPOLLIN, bus_on_connection, m); if (r < 0) { log_error("Failed to allocate event source: %s", strerror(-r)); return r; diff --git a/src/core/device.c b/src/core/device.c index c7bc1e25e7..d17b2dfdd7 100644 --- a/src/core/device.c +++ b/src/core/device.c @@ -534,7 +534,7 @@ static int device_enumerate(Manager *m) { if (r < 0) goto fail; - r = sd_event_add_io(m->event, udev_monitor_get_fd(m->udev_monitor), EPOLLIN, device_dispatch_io, m, &m->udev_event_source); + r = sd_event_add_io(m->event, &m->udev_event_source, udev_monitor_get_fd(m->udev_monitor), EPOLLIN, device_dispatch_io, m); if (r < 0) goto fail; } diff --git a/src/core/job.c b/src/core/job.c index feeb563177..2f998f8958 100644 --- a/src/core/job.c +++ b/src/core/job.c @@ -872,7 +872,7 @@ int job_start_timer(Job *j) { if (j->unit->job_timeout <= 0) return 0; - r = sd_event_add_monotonic(j->manager->event, j->begin_usec + j->unit->job_timeout, 0, job_dispatch_timer, j, &j->timer_event_source); + r = sd_event_add_monotonic(j->manager->event, &j->timer_event_source, j->begin_usec + j->unit->job_timeout, 0, job_dispatch_timer, j); if (r < 0) return r; @@ -1057,7 +1057,7 @@ int job_coldplug(Job *j) { if (j->timer_event_source) j->timer_event_source = sd_event_source_unref(j->timer_event_source); - r = sd_event_add_monotonic(j->manager->event, j->begin_usec + j->unit->job_timeout, 0, job_dispatch_timer, j, &j->timer_event_source); + r = sd_event_add_monotonic(j->manager->event, &j->timer_event_source, j->begin_usec + j->unit->job_timeout, 0, job_dispatch_timer, j); if (r < 0) log_debug("Failed to restart timeout for job: %s", strerror(-r)); diff --git a/src/core/loopback-setup.c b/src/core/loopback-setup.c index e1f725cddb..d0156f2b48 100644 --- a/src/core/loopback-setup.c +++ b/src/core/loopback-setup.c @@ -50,7 +50,7 @@ static int add_addresses(sd_rtnl *rtnl, int if_loopback, struct in_addr *ipv4_ad _cleanup_rtnl_message_unref_ sd_rtnl_message *ipv4 = NULL, *ipv6 = NULL; int r; - r = sd_rtnl_message_new_addr(rtnl, RTM_NEWADDR, if_loopback, AF_INET, &ipv4); + r = sd_rtnl_message_new_addr(rtnl, &ipv4, RTM_NEWADDR, if_loopback, AF_INET); if (r < 0) return r; @@ -79,7 +79,7 @@ static int add_addresses(sd_rtnl *rtnl, int if_loopback, struct in_addr *ipv4_ad if (!socket_ipv6_is_supported()) return 0; - r = sd_rtnl_message_new_addr(rtnl, RTM_NEWADDR, if_loopback, AF_INET6, &ipv6); + r = sd_rtnl_message_new_addr(rtnl, &ipv6, RTM_NEWADDR, if_loopback, AF_INET6); if (r < 0) return r; @@ -112,7 +112,7 @@ static int start_interface(sd_rtnl *rtnl, int if_loopback, struct in_addr *ipv4_ _cleanup_rtnl_message_unref_ sd_rtnl_message *req = NULL; int r; - r = sd_rtnl_message_new_link(rtnl, RTM_SETLINK, if_loopback, &req); + r = sd_rtnl_message_new_link(rtnl, &req, RTM_SETLINK, if_loopback); if (r < 0) return r; @@ -168,7 +168,7 @@ int loopback_setup(void) { ipv4_address.s_addr = htonl(INADDR_LOOPBACK); - r = sd_rtnl_open(0, &rtnl); + r = sd_rtnl_open(&rtnl, 0); if (r < 0) return r; diff --git a/src/core/manager.c b/src/core/manager.c index 388697cdf5..f5801b4749 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -105,7 +105,7 @@ static int manager_watch_jobs_in_progress(Manager *m) { return 0; next = now(CLOCK_MONOTONIC) + JOBS_IN_PROGRESS_WAIT_USEC; - return sd_event_add_monotonic(m->event, next, 0, manager_dispatch_jobs_in_progress, m, &m->jobs_in_progress_event_source); + return sd_event_add_monotonic(m->event, &m->jobs_in_progress_event_source, next, 0, manager_dispatch_jobs_in_progress, m); } #define CYLON_BUFFER_EXTRA (2*(sizeof(ANSI_RED_ON)-1) + sizeof(ANSI_HIGHLIGHT_RED_ON)-1 + 2*(sizeof(ANSI_HIGHLIGHT_OFF)-1)) @@ -209,7 +209,7 @@ static int manager_watch_idle_pipe(Manager *m) { if (m->idle_pipe[2] < 0) return 0; - r = sd_event_add_io(m->event, m->idle_pipe[2], EPOLLIN, manager_dispatch_idle_pipe_fd, m, &m->idle_pipe_event_source); + r = sd_event_add_io(m->event, &m->idle_pipe_event_source, m->idle_pipe[2], EPOLLIN, manager_dispatch_idle_pipe_fd, m); if (r < 0) { log_error("Failed to watch idle pipe: %s", strerror(-r)); return r; @@ -253,7 +253,7 @@ static int manager_setup_time_change(Manager *m) { return 0; } - r = sd_event_add_io(m->event, m->time_change_fd, EPOLLIN, manager_dispatch_time_change_fd, m, &m->time_change_event_source); + r = sd_event_add_io(m->event, &m->time_change_event_source, m->time_change_fd, EPOLLIN, manager_dispatch_time_change_fd, m); if (r < 0) { log_error("Failed to create time change event source: %s", strerror(-r)); return r; @@ -340,7 +340,7 @@ static int manager_setup_signals(Manager *m) { if (m->signal_fd < 0) return -errno; - r = sd_event_add_io(m->event, m->signal_fd, EPOLLIN, manager_dispatch_signal_fd, m, &m->signal_event_source); + r = sd_event_add_io(m->event, &m->signal_event_source, m->signal_fd, EPOLLIN, manager_dispatch_signal_fd, m); if (r < 0) return r; @@ -455,7 +455,7 @@ int manager_new(SystemdRunningAs running_as, Manager **_m) { if (r < 0) goto fail; - r = sd_event_add_defer(m->event, manager_dispatch_run_queue, m, &m->run_queue_event_source); + r = sd_event_add_defer(m->event, &m->run_queue_event_source, manager_dispatch_run_queue, m); if (r < 0) goto fail; @@ -552,7 +552,7 @@ static int manager_setup_notify(Manager *m) { } if (!m->notify_event_source) { - r = sd_event_add_io(m->event, m->notify_fd, EPOLLIN, manager_dispatch_notify_fd, m, &m->notify_event_source); + r = sd_event_add_io(m->event, &m->notify_event_source, m->notify_fd, EPOLLIN, manager_dispatch_notify_fd, m); if (r < 0) { log_error("Failed to allocate notify event source: %s", strerror(-r)); return -errno; diff --git a/src/core/mount.c b/src/core/mount.c index 45c0040bd1..a0cea1e7d4 100644 --- a/src/core/mount.c +++ b/src/core/mount.c @@ -181,7 +181,7 @@ static int mount_arm_timer(Mount *m) { return sd_event_source_set_enabled(m->timer_event_source, SD_EVENT_ONESHOT); } - return sd_event_add_monotonic(UNIT(m)->manager->event, now(CLOCK_MONOTONIC) + m->timeout_usec, 0, mount_dispatch_timer, m, &m->timer_event_source); + return sd_event_add_monotonic(UNIT(m)->manager->event, &m->timer_event_source, now(CLOCK_MONOTONIC) + m->timeout_usec, 0, mount_dispatch_timer, m); } static void mount_unwatch_control_pid(Mount *m) { @@ -1612,7 +1612,7 @@ static int mount_enumerate(Manager *m) { if (!m->proc_self_mountinfo) return -errno; - r = sd_event_add_io(m->event, fileno(m->proc_self_mountinfo), EPOLLPRI, mount_dispatch_io, m, &m->mount_event_source); + r = sd_event_add_io(m->event, &m->mount_event_source, fileno(m->proc_self_mountinfo), EPOLLPRI, mount_dispatch_io, m); if (r < 0) goto fail; diff --git a/src/core/path.c b/src/core/path.c index fc7069e6c7..1d6c6cc6cb 100644 --- a/src/core/path.c +++ b/src/core/path.c @@ -71,7 +71,7 @@ int path_spec_watch(PathSpec *s, sd_event_io_handler_t handler) { goto fail; } - r = sd_event_add_io(s->unit->manager->event, s->inotify_fd, EPOLLIN, handler, s, &s->event_source); + r = sd_event_add_io(s->unit->manager->event, &s->event_source, s->inotify_fd, EPOLLIN, handler, s); if (r < 0) goto fail; diff --git a/src/core/scope.c b/src/core/scope.c index 940e40dda7..16758fed0a 100644 --- a/src/core/scope.c +++ b/src/core/scope.c @@ -88,7 +88,7 @@ static int scope_arm_timer(Scope *s) { return sd_event_source_set_enabled(s->timer_event_source, SD_EVENT_ONESHOT); } - return sd_event_add_monotonic(UNIT(s)->manager->event, now(CLOCK_MONOTONIC) + s->timeout_stop_usec, 0, scope_dispatch_timer, s, &s->timer_event_source); + return sd_event_add_monotonic(UNIT(s)->manager->event, &s->timer_event_source, now(CLOCK_MONOTONIC) + s->timeout_stop_usec, 0, scope_dispatch_timer, s); } static void scope_set_state(Scope *s, ScopeState state) { diff --git a/src/core/service.c b/src/core/service.c index c5ff0dec34..d8e88ea2f0 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -264,7 +264,7 @@ static void service_start_watchdog(Service *s) { r = sd_event_source_set_enabled(s->watchdog_event_source, SD_EVENT_ONESHOT); } else { - r = sd_event_add_monotonic(UNIT(s)->manager->event, s->watchdog_timestamp.monotonic + s->watchdog_usec, 0, service_dispatch_watchdog, s, &s->watchdog_event_source); + r = sd_event_add_monotonic(UNIT(s)->manager->event, &s->watchdog_event_source, s->watchdog_timestamp.monotonic + s->watchdog_usec, 0, service_dispatch_watchdog, s); if (r < 0) { log_warning_unit(UNIT(s)->id, "%s failed to add watchdog timer: %s", UNIT(s)->id, strerror(-r)); return; @@ -354,7 +354,7 @@ static int service_arm_timer(Service *s, usec_t usec) { return sd_event_source_set_enabled(s->timer_event_source, SD_EVENT_ONESHOT); } - return sd_event_add_monotonic(UNIT(s)->manager->event, now(CLOCK_MONOTONIC) + usec, 0, service_dispatch_timer, s, &s->timer_event_source); + return sd_event_add_monotonic(UNIT(s)->manager->event, &s->timer_event_source, now(CLOCK_MONOTONIC) + usec, 0, service_dispatch_timer, s); } #ifdef HAVE_SYSV_COMPAT diff --git a/src/core/socket.c b/src/core/socket.c index 5f16493bc2..0ccda2fe3c 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -175,7 +175,7 @@ static int socket_arm_timer(Socket *s) { return sd_event_source_set_enabled(s->timer_event_source, SD_EVENT_ONESHOT); } - return sd_event_add_monotonic(UNIT(s)->manager->event, now(CLOCK_MONOTONIC) + s->timeout_usec, 0, socket_dispatch_timer, s, &s->timer_event_source); + return sd_event_add_monotonic(UNIT(s)->manager->event, &s->timer_event_source, now(CLOCK_MONOTONIC) + s->timeout_usec, 0, socket_dispatch_timer, s); } static int socket_instantiate_service(Socket *s) { @@ -1112,7 +1112,7 @@ static int socket_watch_fds(Socket *s) { if (p->event_source) r = sd_event_source_set_enabled(p->event_source, SD_EVENT_ON); else - r = sd_event_add_io(UNIT(s)->manager->event, p->fd, EPOLLIN, socket_dispatch_io, p, &p->event_source); + r = sd_event_add_io(UNIT(s)->manager->event, &p->event_source, p->fd, EPOLLIN, socket_dispatch_io, p); if (r < 0) { log_warning_unit(UNIT(s)->id, "Failed to watch listening fds: %s", strerror(-r)); diff --git a/src/core/swap.c b/src/core/swap.c index d53cabef2a..24c4611cbe 100644 --- a/src/core/swap.c +++ b/src/core/swap.c @@ -184,7 +184,7 @@ static int swap_arm_timer(Swap *s) { return sd_event_source_set_enabled(s->timer_event_source, SD_EVENT_ONESHOT); } - return sd_event_add_monotonic(UNIT(s)->manager->event, now(CLOCK_MONOTONIC) + s->timeout_usec, 0, swap_dispatch_timer, s, &s->timer_event_source); + return sd_event_add_monotonic(UNIT(s)->manager->event, &s->timer_event_source, now(CLOCK_MONOTONIC) + s->timeout_usec, 0, swap_dispatch_timer, s); } static int swap_add_device_links(Swap *s) { @@ -1270,7 +1270,7 @@ static int swap_enumerate(Manager *m) { if (!m->proc_swaps) return errno == ENOENT ? 0 : -errno; - r = sd_event_add_io(m->event, fileno(m->proc_swaps), EPOLLPRI, swap_dispatch_io, m, &m->swap_event_source); + r = sd_event_add_io(m->event, &m->swap_event_source, fileno(m->proc_swaps), EPOLLPRI, swap_dispatch_io, m); if (r < 0) goto fail; diff --git a/src/core/timer.c b/src/core/timer.c index a4ff662c5a..1c3ab293b4 100644 --- a/src/core/timer.c +++ b/src/core/timer.c @@ -350,7 +350,7 @@ static void timer_enter_waiting(Timer *t, bool initial) { r = sd_event_source_set_enabled(t->monotonic_event_source, SD_EVENT_ONESHOT); } else - r = sd_event_add_monotonic(UNIT(t)->manager->event, t->next_elapse_monotonic, t->accuracy_usec, timer_dispatch, t, &t->monotonic_event_source); + r = sd_event_add_monotonic(UNIT(t)->manager->event, &t->monotonic_event_source, t->next_elapse_monotonic, t->accuracy_usec, timer_dispatch, t); if (r < 0) goto fail; @@ -376,7 +376,7 @@ static void timer_enter_waiting(Timer *t, bool initial) { r = sd_event_source_set_enabled(t->realtime_event_source, SD_EVENT_ONESHOT); } else - r = sd_event_add_realtime(UNIT(t)->manager->event, t->next_elapse_realtime, t->accuracy_usec, timer_dispatch, t, &t->realtime_event_source); + r = sd_event_add_realtime(UNIT(t)->manager->event, &t->realtime_event_source, t->next_elapse_realtime, t->accuracy_usec, timer_dispatch, t); if (r < 0) goto fail; diff --git a/src/journal/journald-kmsg.c b/src/journal/journald-kmsg.c index 0c8446a3d5..05b128f843 100644 --- a/src/journal/journald-kmsg.c +++ b/src/journal/journald-kmsg.c @@ -403,7 +403,7 @@ int server_open_dev_kmsg(Server *s) { return 0; } - r = sd_event_add_io(s->event, s->dev_kmsg_fd, EPOLLIN, dispatch_dev_kmsg, s, &s->dev_kmsg_event_source); + r = sd_event_add_io(s->event, &s->dev_kmsg_event_source, s->dev_kmsg_fd, EPOLLIN, dispatch_dev_kmsg, s); if (r < 0) { /* This will fail with EPERM on older kernels where diff --git a/src/journal/journald-native.c b/src/journal/journald-native.c index 5e19fa3f55..359d962c72 100644 --- a/src/journal/journald-native.c +++ b/src/journal/journald-native.c @@ -419,7 +419,7 @@ int server_open_native_socket(Server*s) { return -errno; } - r = sd_event_add_io(s->event, s->native_fd, EPOLLIN, process_datagram, s, &s->native_event_source); + r = sd_event_add_io(s->event, &s->native_event_source, s->native_fd, EPOLLIN, process_datagram, s); if (r < 0) { log_error("Failed to add native server fd to event loop: %s", strerror(-r)); return r; diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c index 9ca3859297..5872e91fba 100644 --- a/src/journal/journald-server.c +++ b/src/journal/journald-server.c @@ -1267,19 +1267,19 @@ static int setup_signals(Server *s) { sigset_add_many(&mask, SIGINT, SIGTERM, SIGUSR1, SIGUSR2, -1); assert_se(sigprocmask(SIG_SETMASK, &mask, NULL) == 0); - r = sd_event_add_signal(s->event, SIGUSR1, dispatch_sigusr1, s, &s->sigusr1_event_source); + r = sd_event_add_signal(s->event, &s->sigusr1_event_source, SIGUSR1, dispatch_sigusr1, s); if (r < 0) return r; - r = sd_event_add_signal(s->event, SIGUSR2, dispatch_sigusr2, s, &s->sigusr2_event_source); + r = sd_event_add_signal(s->event, &s->sigusr2_event_source, SIGUSR2, dispatch_sigusr2, s); if (r < 0) return r; - r = sd_event_add_signal(s->event, SIGTERM, dispatch_sigterm, s, &s->sigterm_event_source); + r = sd_event_add_signal(s->event, &s->sigterm_event_source, SIGTERM, dispatch_sigterm, s); if (r < 0) return r; - r = sd_event_add_signal(s->event, SIGINT, dispatch_sigterm, s, &s->sigint_event_source); + r = sd_event_add_signal(s->event, &s->sigint_event_source, SIGINT, dispatch_sigterm, s); if (r < 0) return r; @@ -1387,7 +1387,7 @@ int server_schedule_sync(Server *s, int priority) { when += s->sync_interval_usec; if (!s->sync_event_source) { - r = sd_event_add_monotonic(s->event, when, 0, server_dispatch_sync, s, &s->sync_event_source); + r = sd_event_add_monotonic(s->event, &s->sync_event_source, when, 0, server_dispatch_sync, s); if (r < 0) return r; @@ -1428,7 +1428,7 @@ static int server_open_hostname(Server *s) { return -errno; } - r = sd_event_add_io(s->event, s->hostname_fd, 0, dispatch_hostname_change, s, &s->hostname_event_source); + r = sd_event_add_io(s->event, &s->hostname_event_source, s->hostname_fd, 0, dispatch_hostname_change, s); if (r < 0) { log_error("Failed to register hostname fd in event loop: %s", strerror(-r)); return r; diff --git a/src/journal/journald-stream.c b/src/journal/journald-stream.c index c032ee4a0e..36fc755260 100644 --- a/src/journal/journald-stream.c +++ b/src/journal/journald-stream.c @@ -403,7 +403,7 @@ static int stdout_stream_new(sd_event_source *es, int listen_fd, uint32_t revent goto fail; } - r = sd_event_add_io(s->event, fd, EPOLLIN, stdout_stream_process, stream, &stream->event_source); + r = sd_event_add_io(s->event, &stream->event_source, fd, EPOLLIN, stdout_stream_process, stream); if (r < 0) { log_error("Failed to add stream to event loop: %s", strerror(-r)); goto fail; @@ -460,7 +460,7 @@ int server_open_stdout_socket(Server *s) { } else fd_nonblock(s->stdout_fd, 1); - r = sd_event_add_io(s->event, s->stdout_fd, EPOLLIN, stdout_stream_new, s, &s->stdout_event_source); + r = sd_event_add_io(s->event, &s->stdout_event_source, s->stdout_fd, EPOLLIN, stdout_stream_new, s); if (r < 0) { log_error("Failed to add stdout server fd to event source: %s", strerror(-r)); return r; diff --git a/src/journal/journald-syslog.c b/src/journal/journald-syslog.c index 80eb9ff2db..241f7edb6e 100644 --- a/src/journal/journald-syslog.c +++ b/src/journal/journald-syslog.c @@ -468,7 +468,7 @@ int server_open_syslog_socket(Server *s) { return -errno; } - r = sd_event_add_io(s->event, s->syslog_fd, EPOLLIN, process_datagram, s, &s->syslog_event_source); + r = sd_event_add_io(s->event, &s->syslog_event_source, s->syslog_fd, EPOLLIN, process_datagram, s); if (r < 0) { log_error("Failed to add syslog server fd to event loop: %s", strerror(-r)); return r; diff --git a/src/libsystemd-dhcp/sd-dhcp-client.c b/src/libsystemd-dhcp/sd-dhcp-client.c index ed81ab2d79..ec2b53ffe1 100644 --- a/src/libsystemd-dhcp/sd-dhcp-client.c +++ b/src/libsystemd-dhcp/sd-dhcp-client.c @@ -392,10 +392,11 @@ static int client_timeout_resend(sd_event_source *s, uint64_t usec, next_timeout += (random_u32() & 0x1fffff); - r = sd_event_add_monotonic(client->event, next_timeout, + r = sd_event_add_monotonic(client->event, + &client->timeout_resend, + next_timeout, 10 * USEC_PER_MSEC, - client_timeout_resend, client, - &client->timeout_resend); + client_timeout_resend, client); if (r < 0) goto error; @@ -465,8 +466,9 @@ static int client_initialize_events(sd_dhcp_client *client, assert(client); assert(client->event); - r = sd_event_add_io(client->event, client->fd, EPOLLIN, io_callback, - client, &client->receive_message); + r = sd_event_add_io(client->event, &client->receive_message, + client->fd, EPOLLIN, io_callback, + client); if (r < 0) goto error; @@ -475,9 +477,10 @@ static int client_initialize_events(sd_dhcp_client *client, if (r < 0) goto error; - r = sd_event_add_monotonic(client->event, usec, 0, - client_timeout_resend, client, - &client->timeout_resend); + r = sd_event_add_monotonic(client->event, + &client->timeout_resend, + usec, 0, + client_timeout_resend, client); if (r < 0) goto error; @@ -643,10 +646,11 @@ static int client_set_lease_timeouts(sd_dhcp_client *client, uint64_t usec) { if (next_timeout < usec) return -EINVAL; - r = sd_event_add_monotonic(client->event, next_timeout, + r = sd_event_add_monotonic(client->event, + &client->timeout_t1, + next_timeout, 10 * USEC_PER_MSEC, - client_timeout_t1, client, - &client->timeout_t1); + client_timeout_t1, client); if (r < 0) return r; @@ -669,10 +673,11 @@ static int client_set_lease_timeouts(sd_dhcp_client *client, uint64_t usec) { if (next_timeout < usec) return -EINVAL; - r = sd_event_add_monotonic(client->event, next_timeout, + r = sd_event_add_monotonic(client->event, + &client->timeout_t2, + next_timeout, 10 * USEC_PER_MSEC, - client_timeout_t2, client, - &client->timeout_t2); + client_timeout_t2, client); if (r < 0) return r; @@ -686,10 +691,10 @@ static int client_set_lease_timeouts(sd_dhcp_client *client, uint64_t usec) { if (next_timeout < usec) return -EINVAL; - r = sd_event_add_monotonic(client->event, next_timeout, + r = sd_event_add_monotonic(client->event, + &client->timeout_expire, next_timeout, 10 * USEC_PER_MSEC, - client_timeout_expire, client, - &client->timeout_expire); + client_timeout_expire, client); if (r < 0) return r; @@ -728,10 +733,11 @@ static int client_handle_message(sd_dhcp_client *client, DHCPMessage *message, client->state = DHCP_STATE_REQUESTING; client->attempt = 1; - r = sd_event_add_monotonic(client->event, time_now, 0, + r = sd_event_add_monotonic(client->event, + &client->timeout_resend, + time_now, 0, client_timeout_resend, - client, - &client->timeout_resend); + client); if (r < 0) goto error; 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", ©); + r = sd_bus_message_new_method_call(NULL, ©, "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); diff --git a/src/locale/localectl.c b/src/locale/localectl.c index 5929169fe5..2632305dcc 100644 --- a/src/locale/localectl.c +++ b/src/locale/localectl.c @@ -150,11 +150,13 @@ static int set_locale(sd_bus *bus, char **args, unsigned n) { polkit_agent_open_if_enabled(); - r = sd_bus_message_new_method_call(bus, + r = sd_bus_message_new_method_call( + bus, + &m, "org.freedesktop.locale1", "/org/freedesktop/locale1", "org.freedesktop.locale1", - "SetLocale", &m); + "SetLocale"); if (r < 0) return bus_log_create_error(r); diff --git a/src/locale/localed.c b/src/locale/localed.c index 7a6a96f68f..de6e3b2f84 100644 --- a/src/locale/localed.c +++ b/src/locale/localed.c @@ -366,11 +366,11 @@ static int locale_update_system_manager(Context *c, sd_bus *bus) { } assert(c_set + c_unset == _LOCALE_MAX); - r = sd_bus_message_new_method_call(bus, + r = sd_bus_message_new_method_call(bus, &m, "org.freedesktop.systemd1", "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", - "UnsetAndSetEnvironment", &m); + "UnsetAndSetEnvironment"); if (r < 0) return r; diff --git a/src/login/logind-button.c b/src/login/logind-button.c index e29f2c4c5f..80236c40c1 100644 --- a/src/login/logind-button.c +++ b/src/login/logind-button.c @@ -222,7 +222,7 @@ int button_open(Button *b) { goto fail; } - r = sd_event_add_io(b->manager->event, b->fd, EPOLLIN, button_dispatch, b, &b->event_source); + r = sd_event_add_io(b->manager->event, &b->event_source, b->fd, EPOLLIN, button_dispatch, b); if (r < 0) { log_error("Failed to add button event: %s", strerror(-r)); goto fail; diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c index bd0de33866..fc8953155d 100644 --- a/src/login/logind-dbus.c +++ b/src/login/logind-dbus.c @@ -2192,11 +2192,11 @@ int manager_start_scope( r = sd_bus_message_new_method_call( manager->bus, + &m, "org.freedesktop.systemd1", "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", - "StartTransientUnit", - &m); + "StartTransientUnit"); if (r < 0) return r; diff --git a/src/login/logind-inhibit.c b/src/login/logind-inhibit.c index e261c8e366..d19d648129 100644 --- a/src/login/logind-inhibit.c +++ b/src/login/logind-inhibit.c @@ -300,7 +300,7 @@ int inhibitor_create_fifo(Inhibitor *i) { } if (!i->event_source) { - r = sd_event_add_io(i->manager->event, i->fifo_fd, 0, inhibitor_dispatch_fifo, i, &i->event_source); + r = sd_event_add_io(i->manager->event, &i->event_source, i->fifo_fd, 0, inhibitor_dispatch_fifo, i); if (r < 0) return r; diff --git a/src/login/logind-session-device.c b/src/login/logind-session-device.c index 592bcf2d9f..932abb82f9 100644 --- a/src/login/logind-session-device.c +++ b/src/login/logind-session-device.c @@ -62,10 +62,10 @@ static int session_device_notify(SessionDevice *sd, enum SessionDeviceNotificati return -ENOMEM; r = sd_bus_message_new_signal( - sd->session->manager->bus, path, + sd->session->manager->bus, + &m, path, "org.freedesktop.login1.Session", - (type == SESSION_DEVICE_RESUME) ? "ResumeDevice" : "PauseDevice", - &m); + (type == SESSION_DEVICE_RESUME) ? "ResumeDevice" : "PauseDevice"); if (!m) return r; diff --git a/src/login/logind-session.c b/src/login/logind-session.c index dc1d81c4be..81d12cbcea 100644 --- a/src/login/logind-session.c +++ b/src/login/logind-session.c @@ -683,7 +683,7 @@ void session_release(Session *s) { return; if (!s->timer_event_source) - sd_event_add_monotonic(s->manager->event, now(CLOCK_MONOTONIC) + RELEASE_USEC, 0, release_timeout_callback, s, &s->timer_event_source); + sd_event_add_monotonic(s->manager->event, &s->timer_event_source, now(CLOCK_MONOTONIC) + RELEASE_USEC, 0, release_timeout_callback, s); } bool session_is_active(Session *s) { @@ -844,7 +844,7 @@ int session_create_fifo(Session *s) { } if (!s->fifo_event_source) { - r = sd_event_add_io(s->manager->event, s->fifo_fd, 0, session_dispatch_fifo, s, &s->fifo_event_source); + r = sd_event_add_io(s->manager->event, &s->fifo_event_source, s->fifo_fd, 0, session_dispatch_fifo, s); if (r < 0) return r; @@ -986,7 +986,7 @@ void session_mute_vt(Session *s) { sigaddset(&mask, SIGUSR1); sigprocmask(SIG_BLOCK, &mask, NULL); - r = sd_event_add_signal(s->manager->event, SIGUSR1, session_vt_fn, s, &s->vt_source); + r = sd_event_add_signal(s->manager->event, &s->vt_source, SIGUSR1, session_vt_fn, s); if (r < 0) goto error; diff --git a/src/login/logind.c b/src/login/logind.c index 7aea3cdcb1..28d7058fe2 100644 --- a/src/login/logind.c +++ b/src/login/logind.c @@ -741,7 +741,7 @@ static int manager_connect_console(Manager *m) { return -errno; } - r = sd_event_add_io(m->event, m->console_active_fd, 0, manager_dispatch_console, m, &m->console_active_event_source); + r = sd_event_add_io(m->event, &m->console_active_event_source, m->console_active_fd, 0, manager_dispatch_console, m); if (r < 0) { log_error("Failed to watch foreground console"); return r; @@ -771,7 +771,7 @@ static int manager_connect_udev(Manager *m) { if (r < 0) return r; - r = sd_event_add_io(m->event, udev_monitor_get_fd(m->udev_seat_monitor), EPOLLIN, manager_dispatch_seat_udev, m, &m->udev_seat_event_source); + r = sd_event_add_io(m->event, &m->udev_seat_event_source, udev_monitor_get_fd(m->udev_seat_monitor), EPOLLIN, manager_dispatch_seat_udev, m); if (r < 0) return r; @@ -795,7 +795,7 @@ static int manager_connect_udev(Manager *m) { if (r < 0) return r; - r = sd_event_add_io(m->event, udev_monitor_get_fd(m->udev_device_monitor), EPOLLIN, manager_dispatch_device_udev, m, &m->udev_device_event_source); + r = sd_event_add_io(m->event, &m->udev_device_event_source, udev_monitor_get_fd(m->udev_device_monitor), EPOLLIN, manager_dispatch_device_udev, m); if (r < 0) return r; @@ -821,7 +821,7 @@ static int manager_connect_udev(Manager *m) { if (r < 0) return r; - r = sd_event_add_io(m->event, udev_monitor_get_fd(m->udev_button_monitor), EPOLLIN, manager_dispatch_button_udev, m, &m->udev_button_event_source); + r = sd_event_add_io(m->event, &m->udev_button_event_source, udev_monitor_get_fd(m->udev_button_monitor), EPOLLIN, manager_dispatch_button_udev, m); if (r < 0) return r; } @@ -841,7 +841,7 @@ static int manager_connect_udev(Manager *m) { if (r < 0) return r; - r = sd_event_add_io(m->event, udev_monitor_get_fd(m->udev_vcsa_monitor), EPOLLIN, manager_dispatch_vcsa_udev, m, &m->udev_vcsa_event_source); + r = sd_event_add_io(m->event, &m->udev_vcsa_event_source, udev_monitor_get_fd(m->udev_vcsa_monitor), EPOLLIN, manager_dispatch_vcsa_udev, m); if (r < 0) return r; } @@ -935,7 +935,7 @@ static int manager_dispatch_idle_action(sd_event_source *s, uint64_t t, void *us if (!m->idle_action_event_source) { - r = sd_event_add_monotonic(m->event, elapse, USEC_PER_SEC*30, manager_dispatch_idle_action, m, &m->idle_action_event_source); + r = sd_event_add_monotonic(m->event, &m->idle_action_event_source, elapse, USEC_PER_SEC*30, manager_dispatch_idle_action, m); if (r < 0) { log_error("Failed to add idle event source: %s", strerror(-r)); return r; diff --git a/src/machine/machined-dbus.c b/src/machine/machined-dbus.c index 4a75c34dd0..09d28bbb33 100644 --- a/src/machine/machined-dbus.c +++ b/src/machine/machined-dbus.c @@ -539,11 +539,11 @@ int manager_start_scope( r = sd_bus_message_new_method_call( manager->bus, + &m, "org.freedesktop.systemd1", "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", - "StartTransientUnit", - &m); + "StartTransientUnit"); if (r < 0) return r; 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; diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index 62c2e2ef09..0a00903ef4 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -1315,13 +1315,13 @@ static int setup_veth(pid_t pid, char iface_name[]) { strncpy(iface_name+3, arg_machine, IFNAMSIZ - 3); - r = sd_rtnl_open(0, &rtnl); + r = sd_rtnl_open(&rtnl, 0); if (r < 0) { log_error("Failed to connect to netlink: %s", strerror(-r)); return r; } - r = sd_rtnl_message_new_link(rtnl, RTM_NEWLINK, 0, &m); + r = sd_rtnl_message_new_link(rtnl, &m, RTM_NEWLINK, 0); if (r < 0) { log_error("Failed to allocate netlink message: %s", strerror(-r)); return r; @@ -1416,13 +1416,13 @@ static int setup_bridge(const char veth_name[]) { return -errno; } - r = sd_rtnl_open(0, &rtnl); + r = sd_rtnl_open(&rtnl, 0); if (r < 0) { log_error("Failed to connect to netlink: %s", strerror(-r)); return r; } - r = sd_rtnl_message_new_link(rtnl, RTM_SETLINK, 0, &m); + r = sd_rtnl_message_new_link(rtnl, &m, RTM_SETLINK, 0); if (r < 0) { log_error("Failed to allocate netlink message: %s", strerror(-r)); return r; @@ -1461,7 +1461,7 @@ static int move_network_interfaces(pid_t pid) { if (strv_isempty(arg_network_interfaces)) return 0; - r = sd_rtnl_open(0, &rtnl); + r = sd_rtnl_open(&rtnl, 0); if (r < 0) { log_error("Failed to connect to netlink: %s", strerror(-r)); return r; @@ -1497,7 +1497,7 @@ static int move_network_interfaces(pid_t pid) { return -EBUSY; } - r = sd_rtnl_message_new_link(rtnl, RTM_NEWLINK, ifi, &m); + r = sd_rtnl_message_new_link(rtnl, &m, RTM_NEWLINK, ifi); if (r < 0) { log_error("Failed to allocate netlink message: %s", strerror(-r)); return r; diff --git a/src/run/run.c b/src/run/run.c index 724d67d846..885d881ec6 100644 --- a/src/run/run.c +++ b/src/run/run.c @@ -241,10 +241,11 @@ static int message_start_transient_unit_new(sd_bus *bus, const char *name, sd_bu r = sd_bus_message_new_method_call( bus, + &m, "org.freedesktop.systemd1", "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", - "StartTransientUnit", &m); + "StartTransientUnit"); if (r < 0) return r; diff --git a/src/socket-proxy/socket-proxyd.c b/src/socket-proxy/socket-proxyd.c index b066633b1d..a42e5ae279 100644 --- a/src/socket-proxy/socket-proxyd.c +++ b/src/socket-proxy/socket-proxyd.c @@ -318,7 +318,7 @@ static int connection_enable_event_sources(Connection *c, sd_event *event) { if (c->server_event_source) r = sd_event_source_set_io_events(c->server_event_source, a); else if (c->server_fd >= 0) - r = sd_event_add_io(event, c->server_fd, a, traffic_cb, c, &c->server_event_source); + r = sd_event_add_io(event, &c->server_event_source, c->server_fd, a, traffic_cb, c); else r = 0; @@ -330,7 +330,7 @@ static int connection_enable_event_sources(Connection *c, sd_event *event) { if (c->client_event_source) r = sd_event_source_set_io_events(c->client_event_source, b); else if (c->client_fd >= 0) - r = sd_event_add_io(event, c->client_fd, b, traffic_cb, c, &c->client_event_source); + r = sd_event_add_io(event, &c->client_event_source, c->client_fd, b, traffic_cb, c); else r = 0; @@ -433,7 +433,7 @@ static int add_connection_socket(Context *context, sd_event *event, int fd) { r = connect(c->client_fd, &sa.sa, salen); if (r < 0) { if (errno == EINPROGRESS) { - r = sd_event_add_io(event, c->client_fd, EPOLLOUT, connect_cb, c, &c->client_event_source); + r = sd_event_add_io(event, &c->client_event_source, c->client_fd, EPOLLOUT, connect_cb, c); if (r < 0) { log_error("Failed to add connection socket: %s", strerror(-r)); goto fail; @@ -526,7 +526,7 @@ static int add_listen_socket(Context *context, sd_event *event, int fd) { return r; } - r = sd_event_add_io(event, fd, EPOLLIN, accept_cb, context, &source); + r = sd_event_add_io(event, &source, fd, EPOLLIN, accept_cb, context); if (r < 0) { log_error("Failed to add event source: %s", strerror(-r)); return r; diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index e529095f93..a398206cdd 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -4175,11 +4175,11 @@ static int set_property(sd_bus *bus, char **args) { r = sd_bus_message_new_method_call( bus, + &m, "org.freedesktop.systemd1", "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", - "SetUnitProperties", - &m); + "SetUnitProperties"); if (r < 0) return bus_log_create_error(r); @@ -4490,11 +4490,11 @@ static int set_environment(sd_bus *bus, char **args) { r = sd_bus_message_new_method_call( bus, + &m, "org.freedesktop.systemd1", "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", - method, - &m); + method); if (r < 0) return bus_log_create_error(r); @@ -4521,11 +4521,11 @@ static int import_environment(sd_bus *bus, char **args) { r = sd_bus_message_new_method_call( bus, + &m, "org.freedesktop.systemd1", "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", - "SetEnvironment", - &m); + "SetEnvironment"); if (r < 0) return bus_log_create_error(r); @@ -4849,11 +4849,11 @@ static int enable_unit(sd_bus *bus, char **args) { r = sd_bus_message_new_method_call( bus, + &m, "org.freedesktop.systemd1", "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", - method, - &m); + method); if (r < 0) return bus_log_create_error(r); diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h index 94a435ac6d..0629e47dea 100644 --- a/src/systemd/sd-bus.h +++ b/src/systemd/sd-bus.h @@ -177,12 +177,12 @@ int sd_bus_remove_object_manager(sd_bus *bus, const char *path); /* Message object */ -int sd_bus_message_new_signal(sd_bus *bus, const char *path, const char *interface, const char *member, sd_bus_message **m); -int sd_bus_message_new_method_call(sd_bus *bus, const char *destination, const char *path, const char *interface, const char *member, sd_bus_message **m); +int sd_bus_message_new_signal(sd_bus *bus, sd_bus_message **m, const char *path, const char *interface, const char *member); +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); int sd_bus_message_new_method_return(sd_bus_message *call, sd_bus_message **m); -int sd_bus_message_new_method_error(sd_bus_message *call, const sd_bus_error *e, sd_bus_message **m); +int sd_bus_message_new_method_error(sd_bus_message *call, sd_bus_message **m, const sd_bus_error *e); int sd_bus_message_new_method_errorf(sd_bus_message *call, sd_bus_message **m, const char *name, const char *format, ...) _sd_printf_(4, 5); -int sd_bus_message_new_method_errno(sd_bus_message *call, int error, const sd_bus_error *e, sd_bus_message **m); +int sd_bus_message_new_method_errno(sd_bus_message *call, sd_bus_message **m, int error, const sd_bus_error *e); int sd_bus_message_new_method_errnof(sd_bus_message *call, sd_bus_message **m, int error, const char *format, ...) _sd_printf_(4, 5); sd_bus_message* sd_bus_message_ref(sd_bus_message *m); @@ -284,7 +284,7 @@ int sd_bus_query_sender_creds(sd_bus_message *call, uint64_t mask, sd_bus_creds /* Credential handling */ -int sd_bus_creds_new_from_pid(pid_t pid, uint64_t creds_mask, sd_bus_creds **ret); +int sd_bus_creds_new_from_pid(sd_bus_creds **ret, pid_t pid, uint64_t creds_mask); sd_bus_creds *sd_bus_creds_ref(sd_bus_creds *c); sd_bus_creds *sd_bus_creds_unref(sd_bus_creds *c); uint64_t sd_bus_creds_get_mask(const sd_bus_creds *c); diff --git a/src/systemd/sd-event.h b/src/systemd/sd-event.h index b911485671..68c52c5145 100644 --- a/src/systemd/sd-event.h +++ b/src/systemd/sd-event.h @@ -76,13 +76,13 @@ int sd_event_new(sd_event **e); sd_event* sd_event_ref(sd_event *e); sd_event* sd_event_unref(sd_event *e); -int sd_event_add_io(sd_event *e, int fd, uint32_t events, sd_event_io_handler_t callback, void *userdata, sd_event_source **s); -int sd_event_add_monotonic(sd_event *e, uint64_t usec, uint64_t accuracy, sd_event_time_handler_t callback, void *userdata, sd_event_source **s); -int sd_event_add_realtime(sd_event *e, uint64_t usec, uint64_t accuracy, sd_event_time_handler_t callback, void *userdata, sd_event_source **s); -int sd_event_add_signal(sd_event *e, int sig, sd_event_signal_handler_t callback, void *userdata, sd_event_source **s); -int sd_event_add_child(sd_event *e, pid_t pid, int options, sd_event_child_handler_t callback, void *userdata, sd_event_source **s); -int sd_event_add_defer(sd_event *e, sd_event_handler_t callback, void *userdata, sd_event_source **s); -int sd_event_add_exit(sd_event *e, sd_event_handler_t callback, void *userdata, sd_event_source **s); +int sd_event_add_io(sd_event *e, sd_event_source **s, int fd, uint32_t events, sd_event_io_handler_t callback, void *userdata); +int sd_event_add_monotonic(sd_event *e, sd_event_source **s, uint64_t usec, uint64_t accuracy, sd_event_time_handler_t callback, void *userdata); +int sd_event_add_realtime(sd_event *e, sd_event_source **s, uint64_t usec, uint64_t accuracy, sd_event_time_handler_t callback, void *userdata); +int sd_event_add_signal(sd_event *e, sd_event_source **s, int sig, sd_event_signal_handler_t callback, void *userdata); +int sd_event_add_child(sd_event *e, sd_event_source **s, pid_t pid, int options, sd_event_child_handler_t callback, void *userdata); +int sd_event_add_defer(sd_event *e, sd_event_source **s, sd_event_handler_t callback, void *userdata); +int sd_event_add_exit(sd_event *e, sd_event_source **s, sd_event_handler_t callback, void *userdata); int sd_event_run(sd_event *e, uint64_t timeout); int sd_event_loop(sd_event *e); diff --git a/src/systemd/sd-journal.h b/src/systemd/sd-journal.h index cdd7c14a57..eb24372359 100644 --- a/src/systemd/sd-journal.h +++ b/src/systemd/sd-journal.h @@ -136,7 +136,7 @@ int sd_journal_wait(sd_journal *j, uint64_t timeout_usec); int sd_journal_reliable_fd(sd_journal *j); int sd_journal_get_catalog(sd_journal *j, char **text); -int sd_journal_get_catalog_for_message_id(sd_id128_t id, char **ret); +int sd_journal_get_catalog_for_message_id(sd_id128_t id, char **text); #define SD_JOURNAL_FOREACH(j) \ if (sd_journal_seek_head(j) >= 0) \ diff --git a/src/systemd/sd-memfd.h b/src/systemd/sd-memfd.h index 76cb8751cc..753ed68cd8 100644 --- a/src/systemd/sd-memfd.h +++ b/src/systemd/sd-memfd.h @@ -32,9 +32,9 @@ _SD_BEGIN_DECLARATIONS; typedef struct sd_memfd sd_memfd; -int sd_memfd_new(const char *name, sd_memfd **m); -int sd_memfd_new_and_map(const char *name, sd_memfd **m, size_t sz, void **p); -int sd_memfd_make(int fd, sd_memfd **m); +int sd_memfd_new(sd_memfd **m, const char *name); +int sd_memfd_new_from_fd(sd_memfd **m, int fd); +int sd_memfd_new_and_map(sd_memfd **m, const char *name, size_t sz, void **p); void sd_memfd_free(sd_memfd *m); diff --git a/src/systemd/sd-resolve.h b/src/systemd/sd-resolve.h index 14f45573b0..df69e4b809 100644 --- a/src/systemd/sd-resolve.h +++ b/src/systemd/sd-resolve.h @@ -68,7 +68,7 @@ int sd_resolve_wait(sd_resolve *resolve, uint64_t timeout_usec); * getaddrinfo(3). The function returns a new query object. When the * query is completed you may retrieve the results using * sd_resolve_getaddrinfo_done(). */ -int sd_resolve_getaddrinfo(sd_resolve *resolve, const char *node, const char *service, const struct addrinfo *hints, sd_resolve_query **q); +int sd_resolve_getaddrinfo(sd_resolve *resolve, sd_resolve_query **q, const char *node, const char *service, const struct addrinfo *hints); /** Retrieve the results of a preceding sd_resolve_getaddrinfo() * call. Returns a addrinfo structure and a return value compatible @@ -90,7 +90,7 @@ void sd_resolve_freeaddrinfo(struct addrinfo *ai); * query is completed you may retrieve the results using * sd_resolve_getnameinfo_done(). Set gethost (resp. getserv) to non-zero * if you want to query the hostname (resp. the service name). */ -int sd_resolve_getnameinfo(sd_resolve *resolve, const struct sockaddr *sa, socklen_t salen, int flags, int gethost, int getserv, sd_resolve_query **q); +int sd_resolve_getnameinfo(sd_resolve *resolve, sd_resolve_query **q, const struct sockaddr *sa, socklen_t salen, int flags, int gethost, int getserv); /** Retrieve the results of a preceding sd_resolve_getnameinfo() * call. Returns the hostname and the service name in ret_host and @@ -103,13 +103,13 @@ int sd_resolve_getnameinfo_done(sd_resolve_query* q, char **ret_host, char **ret * compatible with the ones of libc's res_query(3). The function returns a new * query object. When the query is completed you may retrieve the results using * sd_resolve_res_done(). */ -int sd_resolve_res_query(sd_resolve *resolve, const char *dname, int class, int type, sd_resolve_query **q); +int sd_resolve_res_query(sd_resolve *resolve, sd_resolve_query **q, const char *dname, int class, int type); /** Issue an resolver query on the specified session. The arguments are * compatible with the ones of libc's res_search(3). The function returns a new * query object. When the query is completed you may retrieve the results using * sd_resolve_res_done(). */ -int sd_resolve_res_search(sd_resolve *resolve, const char *dname, int class, int type, sd_resolve_query **q); +int sd_resolve_res_search(sd_resolve *resolve, sd_resolve_query **q, const char *dname, int class, int type); /** Retrieve the results of a preceding sd_resolve_res_query() or * resolve_res_search call. The query object q is destroyed by this diff --git a/src/systemd/sd-rtnl.h b/src/systemd/sd-rtnl.h index 502183e9e8..f2b3a53fd6 100644 --- a/src/systemd/sd-rtnl.h +++ b/src/systemd/sd-rtnl.h @@ -40,7 +40,7 @@ typedef struct sd_rtnl_message sd_rtnl_message; typedef int (*sd_rtnl_message_handler_t)(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata); /* bus */ -int sd_rtnl_open(uint32_t groups, sd_rtnl **nl); +int sd_rtnl_open(sd_rtnl **nl, uint32_t groups); sd_rtnl *sd_rtnl_ref(sd_rtnl *nl); sd_rtnl *sd_rtnl_unref(sd_rtnl *nl); @@ -67,12 +67,11 @@ int sd_rtnl_attach_event(sd_rtnl *nl, sd_event *e, int priority); int sd_rtnl_detach_event(sd_rtnl *nl); /* messages */ -int sd_rtnl_message_new_link(sd_rtnl *rtnl, uint16_t msg_type, int index, - sd_rtnl_message **ret); -int sd_rtnl_message_new_addr(sd_rtnl *rtnl, uint16_t msg_type, int index, - unsigned char family, sd_rtnl_message **ret); -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_link(sd_rtnl *rtnl, sd_rtnl_message **ret, uint16_t msg_type, int index); +int sd_rtnl_message_new_addr(sd_rtnl *rtnl, sd_rtnl_message **ret, uint16_t msg_type, int index, + unsigned char family); +int sd_rtnl_message_new_route(sd_rtnl *rtnl, sd_rtnl_message **ret, uint16_t nlmsg_type, + unsigned char rtm_family); sd_rtnl_message *sd_rtnl_message_ref(sd_rtnl_message *m); sd_rtnl_message *sd_rtnl_message_unref(sd_rtnl_message *m); diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c index d05b909913..587eeefada 100644 --- a/src/udev/net/link-config.c +++ b/src/udev/net/link-config.c @@ -97,7 +97,7 @@ static int link_config_ctx_connect(link_config_ctx *ctx) { if (r < 0) return r; - r = sd_rtnl_open(0, &ctx->rtnl); + r = sd_rtnl_open(&ctx->rtnl, 0); if (r < 0) return r; diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c index 8eb1e2b7ec..0b3ade082c 100644 --- a/src/udev/udev-event.c +++ b/src/udev/udev-event.c @@ -760,7 +760,7 @@ static int rename_netif(struct udev_event *event) strscpy(name, IFNAMSIZ, event->name); - r = sd_rtnl_open(0, &rtnl); + r = sd_rtnl_open(&rtnl, 0); if (r < 0) return r; |