tree-wide: don't do assignments within if checks
Turn this: if ((r = foo()) < 0) { ... into this: r = foo(); if (r < 0) { ...
This commit is contained in:
parent
7f6e12b033
commit
3cc2aff1ab
|
@ -0,0 +1,20 @@
|
||||||
|
@@
|
||||||
|
expression p, q;
|
||||||
|
identifier r;
|
||||||
|
statement s;
|
||||||
|
@@
|
||||||
|
- if ((r = q) < p)
|
||||||
|
- s
|
||||||
|
+ r = q;
|
||||||
|
+ if (r < p)
|
||||||
|
+ s
|
||||||
|
@@
|
||||||
|
expression p, q;
|
||||||
|
identifier r;
|
||||||
|
statement s;
|
||||||
|
@@
|
||||||
|
- if ((r = q) >= p)
|
||||||
|
- s
|
||||||
|
+ r = q;
|
||||||
|
+ if (r >= p)
|
||||||
|
+ s
|
|
@ -156,7 +156,9 @@ int main(int argc, char *argv[]) {
|
||||||
if (arg_use_tty && isatty(STDIN_FILENO)) {
|
if (arg_use_tty && isatty(STDIN_FILENO)) {
|
||||||
char *password = NULL;
|
char *password = NULL;
|
||||||
|
|
||||||
if ((r = ask_password_tty(arg_message, timeout, arg_echo, NULL, &password)) >= 0) {
|
r = ask_password_tty(arg_message, timeout, arg_echo, NULL,
|
||||||
|
&password);
|
||||||
|
if (r >= 0) {
|
||||||
puts(password);
|
puts(password);
|
||||||
free(password);
|
free(password);
|
||||||
}
|
}
|
||||||
|
@ -164,7 +166,9 @@ int main(int argc, char *argv[]) {
|
||||||
} else {
|
} else {
|
||||||
char **l;
|
char **l;
|
||||||
|
|
||||||
if ((r = ask_password_agent(arg_message, arg_icon, arg_id, timeout, arg_echo, arg_accept_cached, &l)) >= 0) {
|
r = ask_password_agent(arg_message, arg_icon, arg_id, timeout,
|
||||||
|
arg_echo, arg_accept_cached, &l);
|
||||||
|
if (r >= 0) {
|
||||||
char **p;
|
char **p;
|
||||||
|
|
||||||
STRV_FOREACH(p, l) {
|
STRV_FOREACH(p, l) {
|
||||||
|
|
|
@ -201,9 +201,11 @@ int fdset_cloexec(FDSet *fds, bool b) {
|
||||||
|
|
||||||
assert(fds);
|
assert(fds);
|
||||||
|
|
||||||
SET_FOREACH(p, MAKE_SET(fds), i)
|
SET_FOREACH(p, MAKE_SET(fds), i) {
|
||||||
if ((r = fd_cloexec(PTR_TO_FD(p), b)) < 0)
|
r = fd_cloexec(PTR_TO_FD(p), b);
|
||||||
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,8 @@ static int shift_fds(int fds[], unsigned n_fds) {
|
||||||
if (fds[i] == i+3)
|
if (fds[i] == i+3)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((nfd = fcntl(fds[i], F_DUPFD, i+3)) < 0)
|
nfd = fcntl(fds[i], F_DUPFD, i + 3);
|
||||||
|
if (nfd < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
safe_close(fds[i]);
|
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++) {
|
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;
|
return r;
|
||||||
|
|
||||||
/* We unconditionally drop FD_CLOEXEC from the fds,
|
/* We unconditionally drop FD_CLOEXEC from the fds,
|
||||||
* since after all we want to pass these fds to our
|
* since after all we want to pass these fds to our
|
||||||
* children */
|
* children */
|
||||||
|
|
||||||
if ((r = fd_cloexec(fds[i], false)) < 0)
|
r = fd_cloexec(fds[i], false);
|
||||||
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,7 +318,8 @@ static int open_terminal_as(const char *path, mode_t mode, int nfd) {
|
||||||
assert(path);
|
assert(path);
|
||||||
assert(nfd >= 0);
|
assert(nfd >= 0);
|
||||||
|
|
||||||
if ((fd = open_terminal(path, mode | O_NOCTTY)) < 0)
|
fd = open_terminal(path, mode | O_NOCTTY);
|
||||||
|
if (fd < 0)
|
||||||
return fd;
|
return fd;
|
||||||
|
|
||||||
if (fd != nfd) {
|
if (fd != nfd) {
|
||||||
|
@ -629,7 +633,8 @@ static int enforce_groups(const ExecContext *context, const char *username, gid_
|
||||||
if (context->group) {
|
if (context->group) {
|
||||||
const char *g = 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;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -658,7 +663,8 @@ static int enforce_groups(const ExecContext *context, const char *username, gid_
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
if (keep_groups) {
|
if (keep_groups) {
|
||||||
if ((k = getgroups(ngroups_max, gids)) < 0) {
|
k = getgroups(ngroups_max, gids);
|
||||||
|
if (k < 0) {
|
||||||
free(gids);
|
free(gids);
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
|
|
|
@ -982,7 +982,9 @@ static int fifo_address_create(
|
||||||
goto fail;
|
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;
|
r = -errno;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
|
@ -464,9 +464,11 @@ static int transaction_verify_order(Transaction *tr, unsigned *generation, sd_bu
|
||||||
|
|
||||||
g = (*generation)++;
|
g = (*generation)++;
|
||||||
|
|
||||||
HASHMAP_FOREACH(j, tr->jobs, i)
|
HASHMAP_FOREACH(j, tr->jobs, i) {
|
||||||
if ((r = transaction_verify_order_one(tr, j, NULL, g, e)) < 0)
|
r = transaction_verify_order_one(tr, j, NULL, g, e);
|
||||||
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -399,13 +399,10 @@ int main(int argc, char *argv[]) {
|
||||||
struct epoll_event event;
|
struct epoll_event event;
|
||||||
int k;
|
int k;
|
||||||
|
|
||||||
if ((k = epoll_wait(server.epoll_fd,
|
k = epoll_wait(server.epoll_fd, &event, 1, TIMEOUT_MSEC);
|
||||||
&event, 1,
|
if (k < 0) {
|
||||||
TIMEOUT_MSEC)) < 0) {
|
|
||||||
|
|
||||||
if (errno == EINTR)
|
if (errno == EINTR)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
log_error_errno(errno, "epoll_wait() failed: %m");
|
log_error_errno(errno, "epoll_wait() failed: %m");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,8 @@ int main(int argc, char* argv[]) {
|
||||||
log_open();
|
log_open();
|
||||||
log_parse_environment();
|
log_parse_environment();
|
||||||
|
|
||||||
if ((r = loopback_setup()) < 0)
|
r = loopback_setup();
|
||||||
|
if (r < 0)
|
||||||
fprintf(stderr, "loopback: %s\n", strerror(-r));
|
fprintf(stderr, "loopback: %s\n", strerror(-r));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue