summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-02-19 23:54:58 +0100
committerLennart Poettering <lennart@poettering.net>2014-02-20 00:03:10 +0100
commit151b9b9662a90455262ce575a8a8ae74bf4ff336 (patch)
tree3e82f3233050d75d23fd69bfdd83aa850727395a /src/core
parent3db729cb8e6822114e9323f4041dcdc080f2fb3c (diff)
api: in constructor function calls, always put the returned object pointer first (or second)
Previously the returned object of constructor functions where sometimes returned as last, sometimes as first and sometimes as second parameter. Let's clean this up a bit. Here are the new rules: 1. The object the new object is derived from is put first, if there is any 2. The object we are creating will be returned in the next arguments 3. This is followed by any additional arguments Rationale: For functions that operate on an object we always put that object first. Constructors should probably not be too different in this regard. Also, if the additional parameters might want to use varargs which suggests to put them last. Note that this new scheme only applies to constructor functions, not to all other functions. We do give a lot of freedom for those. Note that this commit only changes the order of the new functions we added, for old ones we accept the wrong order and leave it like that.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/automount.c4
-rw-r--r--src/core/busname.c2
-rw-r--r--src/core/dbus-job.c8
-rw-r--r--src/core/dbus-manager.c6
-rw-r--r--src/core/dbus-scope.c4
-rw-r--r--src/core/dbus-unit.c8
-rw-r--r--src/core/dbus.c4
-rw-r--r--src/core/device.c2
-rw-r--r--src/core/job.c4
-rw-r--r--src/core/loopback-setup.c8
-rw-r--r--src/core/manager.c12
-rw-r--r--src/core/mount.c4
-rw-r--r--src/core/path.c2
-rw-r--r--src/core/scope.c2
-rw-r--r--src/core/service.c4
-rw-r--r--src/core/socket.c4
-rw-r--r--src/core/swap.c4
-rw-r--r--src/core/timer.c4
18 files changed, 43 insertions, 43 deletions
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;