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 /src/login | |
parent | 3db729cb8e6822114e9323f4041dcdc080f2fb3c (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/login')
-rw-r--r-- | src/login/logind-button.c | 2 | ||||
-rw-r--r-- | src/login/logind-dbus.c | 4 | ||||
-rw-r--r-- | src/login/logind-inhibit.c | 2 | ||||
-rw-r--r-- | src/login/logind-session-device.c | 6 | ||||
-rw-r--r-- | src/login/logind-session.c | 6 | ||||
-rw-r--r-- | src/login/logind.c | 12 |
6 files changed, 16 insertions, 16 deletions
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; |