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/journal | |
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/journal')
-rw-r--r-- | src/journal/journald-kmsg.c | 2 | ||||
-rw-r--r-- | src/journal/journald-native.c | 2 | ||||
-rw-r--r-- | src/journal/journald-server.c | 12 | ||||
-rw-r--r-- | src/journal/journald-stream.c | 4 | ||||
-rw-r--r-- | src/journal/journald-syslog.c | 2 |
5 files changed, 11 insertions, 11 deletions
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; |