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/libsystemd/sd-resolve/sd-resolve.c | |
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/libsystemd/sd-resolve/sd-resolve.c')
-rw-r--r-- | src/libsystemd/sd-resolve/sd-resolve.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/libsystemd/sd-resolve/sd-resolve.c b/src/libsystemd/sd-resolve/sd-resolve.c index 803190f02b..f05fe10b6a 100644 --- a/src/libsystemd/sd-resolve/sd-resolve.c +++ b/src/libsystemd/sd-resolve/sd-resolve.c @@ -914,10 +914,10 @@ static int alloc_query(sd_resolve *resolve, sd_resolve_query **_q) { _public_ int sd_resolve_getaddrinfo( sd_resolve *resolve, + sd_resolve_query **_q, const char *node, const char *service, - const struct addrinfo *hints, - sd_resolve_query **_q) { + const struct addrinfo *hints) { AddrInfoRequest req = {}; struct msghdr mh = {}; @@ -1007,10 +1007,10 @@ _public_ int sd_resolve_getaddrinfo_done(sd_resolve_query* q, struct addrinfo ** _public_ int sd_resolve_getnameinfo( sd_resolve *resolve, + sd_resolve_query**_q, const struct sockaddr *sa, socklen_t salen, int flags, - int gethost, int getserv, - sd_resolve_query**_q) { + int gethost, int getserv) { NameInfoRequest req = {}; struct msghdr mh = {}; @@ -1098,10 +1098,10 @@ _public_ int sd_resolve_getnameinfo_done(sd_resolve_query* q, char **ret_host, c static int resolve_res( sd_resolve *resolve, + sd_resolve_query **_q, QueryType qtype, const char *dname, - int class, int type, - sd_resolve_query **_q) { + int class, int type) { struct msghdr mh = {}; struct iovec iov[2]; @@ -1141,12 +1141,12 @@ static int resolve_res( return 0; } -_public_ int sd_resolve_res_query(sd_resolve *resolve, const char *dname, int class, int type, sd_resolve_query** q) { - return resolve_res(resolve, REQUEST_RES_QUERY, dname, class, type, q); +_public_ int sd_resolve_res_query(sd_resolve *resolve, sd_resolve_query** q, const char *dname, int class, int type) { + return resolve_res(resolve, q, REQUEST_RES_QUERY, dname, class, type); } -_public_ int sd_resolve_res_search(sd_resolve *resolve, const char *dname, int class, int type, sd_resolve_query** q) { - return resolve_res(resolve, REQUEST_RES_SEARCH, dname, class, type, q); +_public_ int sd_resolve_res_search(sd_resolve *resolve, sd_resolve_query** q, const char *dname, int class, int type) { + return resolve_res(resolve, q, REQUEST_RES_SEARCH, dname, class, type); } _public_ int sd_resolve_res_done(sd_resolve_query* q, unsigned char **answer) { |