summaryrefslogtreecommitdiff
path: root/src/libsystemd-bus/sd-dns.c
diff options
context:
space:
mode:
authorDaniel Buch <boogiewasthere@gmail.com>2014-01-12 19:42:33 +0100
committerTom Gundersen <teg@jklm.no>2014-01-13 00:08:42 +0100
commit8e50b5a77cd980ee57e0f75c59d0012d8df9a4f2 (patch)
treecf9b97bb1600fd7947771f5e7141371fd93a1ab3 /src/libsystemd-bus/sd-dns.c
parentf3621dec5234757a8424b90431b681853e9effa2 (diff)
sd-dns: coding style cleanup
Diffstat (limited to 'src/libsystemd-bus/sd-dns.c')
-rw-r--r--src/libsystemd-bus/sd-dns.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/src/libsystemd-bus/sd-dns.c b/src/libsystemd-bus/sd-dns.c
index 8126cb38af..0f90d020ad 100644
--- a/src/libsystemd-bus/sd-dns.c
+++ b/src/libsystemd-bus/sd-dns.c
@@ -229,7 +229,8 @@ static int send_addrinfo_reply(int out_fd, unsigned id, int ret, struct addrinfo
struct addrinfo *k;
for (k = ai; k; k = k->ai_next) {
- if (!(p = serialize_addrinfo(p, k, &resp->header.length, (char*) data + BUFSIZE - (char*) p))) {
+ p = serialize_addrinfo(p, k, &resp->header.length, (char*) data + BUFSIZE - (char*) p);
+ if (!p) {
resp->ret = EAI_MEMORY;
break;
}
@@ -457,8 +458,8 @@ asyncns_t* asyncns_new(unsigned n_proc) {
for (asyncns->valid_workers = 0; asyncns->valid_workers < n_proc; asyncns->valid_workers++) {
int r;
-
- if ((r = pthread_create(&asyncns->workers[asyncns->valid_workers], NULL, thread_worker, asyncns)) != 0) {
+ r = pthread_create(&asyncns->workers[asyncns->valid_workers], NULL, thread_worker, asyncns);
+ if (r) {
errno = r;
goto fail;
}
@@ -532,7 +533,8 @@ static asyncns_query_t *lookup_query(asyncns_t *asyncns, unsigned id) {
asyncns_query_t *q;
assert(asyncns);
- if ((q = asyncns->queries[id % MAX_QUERIES]))
+ q = asyncns->queries[id % MAX_QUERIES];
+ if (q)
if (q->id == id)
return q;
@@ -572,7 +574,8 @@ static const void *unserialize_addrinfo(const void *p, struct addrinfo **ret_ai,
if (*length < l)
return NULL;
- if (!(ai = malloc(sizeof(struct addrinfo))))
+ ai = malloc(sizeof(struct addrinfo));
+ if (!ai)
goto fail;
ai->ai_addr = NULL;
@@ -626,7 +629,8 @@ static int handle_response(asyncns_t *asyncns, const packet_t *packet, size_t le
return 0;
}
- if (!(q = lookup_query(asyncns, resp->id)))
+ q = lookup_query(asyncns, resp->id);
+ if (!q)
return 0;
switch (resp->type) {
@@ -730,7 +734,8 @@ int asyncns_wait(asyncns_t *asyncns, int block) {
return -1;
}
- if (((l = recv(asyncns->fds[RESPONSE_RECV_FD], buf, sizeof(buf), 0)) < 0)) {
+ l = recv(asyncns->fds[RESPONSE_RECV_FD], buf, sizeof(buf), 0);
+ if (l < 0) {
fd_set fds;
if (errno != EAGAIN)
@@ -765,7 +770,6 @@ static asyncns_query_t *alloc_query(asyncns_t *asyncns) {
}
while (asyncns->queries[asyncns->current_index]) {
-
asyncns->current_index++;
asyncns->current_id++;
@@ -773,7 +777,8 @@ static asyncns_query_t *alloc_query(asyncns_t *asyncns) {
asyncns->current_index -= MAX_QUERIES;
}
- if (!(q = asyncns->queries[asyncns->current_index] = malloc(sizeof(asyncns_query_t)))) {
+ q = asyncns->queries[asyncns->current_index] = malloc(sizeof(asyncns_query_t));
+ if (!q) {
errno = ENOMEM;
return NULL;
}
@@ -806,10 +811,10 @@ asyncns_query_t* asyncns_getaddrinfo(asyncns_t *asyncns, const char *node, const
return NULL;
}
- if (!(q = alloc_query(asyncns)))
+ q = alloc_query(asyncns);
+ if (!q)
return NULL;
-
req->node_len = node ? strlen(node)+1 : 0;
req->service_len = service ? strlen(service)+1 : 0;
@@ -892,10 +897,10 @@ asyncns_query_t* asyncns_getnameinfo(asyncns_t *asyncns, const struct sockaddr *
return NULL;
}
- if (!(q = alloc_query(asyncns)))
+ q = alloc_query(asyncns);
+ if (!q)
return NULL;
-
req->header.id = q->id;
req->header.type = q->type = REQUEST_NAMEINFO;
req->header.length = sizeof(nameinfo_request_t) + salen;
@@ -977,7 +982,8 @@ static asyncns_query_t * asyncns_res(asyncns_t *asyncns, query_type_t qtype, con
return NULL;
}
- if (!(q = alloc_query(asyncns)))
+ q = alloc_query(asyncns);
+ if (!q)
return NULL;
req->dname_len = strlen(dname) + 1;