summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-09-08 19:14:10 +0200
committerLennart Poettering <lennart@poettering.net>2015-09-09 08:20:20 +0200
commit3cc2aff1abff9e34f9fec282d970204dc1eab6f1 (patch)
tree39d4b5f8f9980aeacaf64b4c3078f51a46a3b63e /src/core
parent7f6e12b03300ba3e473ce6b85d823fc0375b335e (diff)
tree-wide: don't do assignments within if checks
Turn this: if ((r = foo()) < 0) { ... into this: r = foo(); if (r < 0) { ...
Diffstat (limited to 'src/core')
-rw-r--r--src/core/execute.c18
-rw-r--r--src/core/socket.c4
-rw-r--r--src/core/transaction.c6
3 files changed, 19 insertions, 9 deletions
diff --git a/src/core/execute.c b/src/core/execute.c
index de5c16bd76..3e20130f0e 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -122,7 +122,8 @@ static int shift_fds(int fds[], unsigned n_fds) {
if (fds[i] == i+3)
continue;
- if ((nfd = fcntl(fds[i], F_DUPFD, i+3)) < 0)
+ nfd = fcntl(fds[i], F_DUPFD, i + 3);
+ if (nfd < 0)
return -errno;
safe_close(fds[i]);
@@ -156,14 +157,16 @@ static int flags_fds(const int fds[], unsigned n_fds, bool nonblock) {
for (i = 0; i < n_fds; i++) {
- if ((r = fd_nonblock(fds[i], nonblock)) < 0)
+ r = fd_nonblock(fds[i], nonblock);
+ if (r < 0)
return r;
/* We unconditionally drop FD_CLOEXEC from the fds,
* since after all we want to pass these fds to our
* children */
- if ((r = fd_cloexec(fds[i], false)) < 0)
+ r = fd_cloexec(fds[i], false);
+ if (r < 0)
return r;
}
@@ -315,7 +318,8 @@ static int open_terminal_as(const char *path, mode_t mode, int nfd) {
assert(path);
assert(nfd >= 0);
- if ((fd = open_terminal(path, mode | O_NOCTTY)) < 0)
+ fd = open_terminal(path, mode | O_NOCTTY);
+ if (fd < 0)
return fd;
if (fd != nfd) {
@@ -629,7 +633,8 @@ static int enforce_groups(const ExecContext *context, const char *username, gid_
if (context->group) {
const char *g = context->group;
- if ((r = get_group_creds(&g, &gid)) < 0)
+ r = get_group_creds(&g, &gid);
+ if (r < 0)
return r;
}
@@ -658,7 +663,8 @@ static int enforce_groups(const ExecContext *context, const char *username, gid_
return -ENOMEM;
if (keep_groups) {
- if ((k = getgroups(ngroups_max, gids)) < 0) {
+ k = getgroups(ngroups_max, gids);
+ if (k < 0) {
free(gids);
return -errno;
}
diff --git a/src/core/socket.c b/src/core/socket.c
index 7d3d5eb78a..9db42a0333 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -982,7 +982,9 @@ static int fifo_address_create(
goto fail;
}
- if ((fd = open(path, O_RDWR|O_CLOEXEC|O_NOCTTY|O_NONBLOCK|O_NOFOLLOW)) < 0) {
+ fd = open(path,
+ O_RDWR | O_CLOEXEC | O_NOCTTY | O_NONBLOCK | O_NOFOLLOW);
+ if (fd < 0) {
r = -errno;
goto fail;
}
diff --git a/src/core/transaction.c b/src/core/transaction.c
index 090103fbda..b505297e23 100644
--- a/src/core/transaction.c
+++ b/src/core/transaction.c
@@ -464,9 +464,11 @@ static int transaction_verify_order(Transaction *tr, unsigned *generation, sd_bu
g = (*generation)++;
- HASHMAP_FOREACH(j, tr->jobs, i)
- if ((r = transaction_verify_order_one(tr, j, NULL, g, e)) < 0)
+ HASHMAP_FOREACH(j, tr->jobs, i) {
+ r = transaction_verify_order_one(tr, j, NULL, g, e);
+ if (r < 0)
return r;
+ }
return 0;
}