summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-bus/bus-message.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-bus/bus-message.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-bus/bus-message.c')
-rw-r--r--src/libsystemd/sd-bus/bus-message.c28
1 files changed, 14 insertions, 14 deletions
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;