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