various: use _NEG_ macros to reduce indentation

No functional change intended.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2023-08-16 12:52:56 +02:00
parent 1f2db2e315
commit bb44fd0734
23 changed files with 188 additions and 255 deletions
+13 -17
View File
@@ -158,16 +158,14 @@ static int ask_password_keyring(const char *keyname, AskPasswordFlags flags, cha
return -EUNATCH;
r = lookup_key(keyname, &serial);
if (r < 0) {
/* when retrieving the distinction between "kernel or container manager don't support
* or allow this" and "no matching key known" doesn't matter. Note that we propagate
* EACCESS here (even if EPERM not) since that is used if the keyring is available but
* we lack access to the key. */
if (ERRNO_IS_NOT_SUPPORTED(r) || r == -EPERM)
return -ENOKEY;
if (ERRNO_IS_NEG_NOT_SUPPORTED(r) || r == -EPERM)
/* When retrieving, the distinction between "kernel or container manager don't support or
* allow this" and "no matching key known" doesn't matter. Note that we propagate EACCESS
* here (even if EPERM not) since that is used if the keyring is available, but we lack
* access to the key. */
return -ENOKEY;
if (r < 0)
return r;
}
return retrieve_key(serial, ret);
}
@@ -867,14 +865,12 @@ int ask_password_agent(
};
n = recvmsg_safe(socket_fd, &msghdr, 0);
if (n < 0) {
if (ERRNO_IS_TRANSIENT(n))
continue;
if (n == -EXFULL) {
log_debug("Got message with truncated control data, ignoring.");
continue;
}
if (ERRNO_IS_NEG_TRANSIENT(n))
continue;
else if (n == -EXFULL) {
log_debug("Got message with truncated control data, ignoring.");
continue;
} else if (n < 0) {
r = (int) n;
goto finish;
}
+8 -14
View File
@@ -844,14 +844,11 @@ static int fd_copy_fifo(
r = RET_NERRNO(mkfifoat(dt, to, st->st_mode & 07777));
if (copy_flags & COPY_MAC_CREATE)
mac_selinux_create_file_clear();
if (r < 0) {
if (FLAGS_SET(copy_flags, COPY_GRACEFUL_WARN) && (ERRNO_IS_PRIVILEGE(r) || ERRNO_IS_NOT_SUPPORTED(r))) {
log_notice_errno(r, "Failed to copy fifo '%s', ignoring: %m", from);
return 0;
}
if (FLAGS_SET(copy_flags, COPY_GRACEFUL_WARN) && (ERRNO_IS_NEG_PRIVILEGE(r) || ERRNO_IS_NEG_NOT_SUPPORTED(r))) {
log_notice_errno(r, "Failed to copy fifo '%s', ignoring: %m", from);
return 0;
} else if (r < 0)
return r;
}
if (fchownat(dt, to,
uid_is_valid(override_uid) ? override_uid : st->st_uid,
@@ -898,14 +895,11 @@ static int fd_copy_node(
r = RET_NERRNO(mknodat(dt, to, st->st_mode, st->st_rdev));
if (copy_flags & COPY_MAC_CREATE)
mac_selinux_create_file_clear();
if (r < 0) {
if (FLAGS_SET(copy_flags, COPY_GRACEFUL_WARN) && (ERRNO_IS_PRIVILEGE(r) || ERRNO_IS_NOT_SUPPORTED(r))) {
log_notice_errno(r, "Failed to copy node '%s', ignoring: %m", from);
return 0;
}
if (FLAGS_SET(copy_flags, COPY_GRACEFUL_WARN) && (ERRNO_IS_NEG_PRIVILEGE(r) || ERRNO_IS_NEG_NOT_SUPPORTED(r))) {
log_notice_errno(r, "Failed to copy node '%s', ignoring: %m", from);
return 0;
} else if (r < 0)
return r;
}
if (fchownat(dt, to,
uid_is_valid(override_uid) ? override_uid : st->st_uid,
+5 -7
View File
@@ -82,14 +82,12 @@ int get_keymaps(char ***ret) {
&(struct recurse_dir_userdata) {
.keymaps = keymaps,
});
if (r < 0) {
if (r == -ENOENT)
continue;
if (ERRNO_IS_RESOURCE(r))
return log_warning_errno(r, "Failed to read keymap list from %s: %m", dir);
if (r == -ENOENT)
continue;
if (ERRNO_IS_NEG_RESOURCE(r))
return log_warning_errno(r, "Failed to read keymap list from %s: %m", dir);
if (r < 0)
log_debug_errno(r, "Failed to read keymap list from %s, ignoring: %m", dir);
}
}
_cleanup_strv_free_ char **l = set_get_strv(keymaps);
+14 -16
View File
@@ -57,14 +57,13 @@ static int load_user(
}
r = json_parse_file(NULL, j, JSON_PARSE_SENSITIVE, &privileged_v, NULL, NULL);
if (r < 0) {
if (ERRNO_IS_PRIVILEGE(r))
have_privileged = false;
else if (r == -ENOENT)
have_privileged = true; /* if the privileged file doesn't exist, we are complete */
else
return r;
} else {
if (ERRNO_IS_NEG_PRIVILEGE(r))
have_privileged = false;
else if (r == -ENOENT)
have_privileged = true; /* if the privileged file doesn't exist, we are complete */
else if (r < 0)
return r;
else {
r = json_variant_merge(&v, privileged_v);
if (r < 0)
return r;
@@ -202,14 +201,13 @@ static int load_group(
}
r = json_parse_file(NULL, j, JSON_PARSE_SENSITIVE, &privileged_v, NULL, NULL);
if (r < 0) {
if (ERRNO_IS_PRIVILEGE(r))
have_privileged = false;
else if (r == -ENOENT)
have_privileged = true; /* if the privileged file doesn't exist, we are complete */
else
return r;
} else {
if (ERRNO_IS_NEG_PRIVILEGE(r))
have_privileged = false;
else if (r == -ENOENT)
have_privileged = true; /* if the privileged file doesn't exist, we are complete */
else if (r < 0)
return r;
else {
r = json_variant_merge(&v, privileged_v);
if (r < 0)
return r;
+3 -4
View File
@@ -313,11 +313,10 @@ static int write_to_terminal(const char *tty, const char *message) {
return -ETIME;
k = fd_wait_for_event(fd, POLLOUT, end - t);
if (k < 0) {
if (ERRNO_IS_TRANSIENT(k))
continue;
if (ERRNO_IS_NEG_TRANSIENT(k))
continue;
if (k < 0)
return k;
}
if (k == 0)
return -ETIME;
+4 -7
View File
@@ -1368,14 +1368,11 @@ int varlink_flush(Varlink *v) {
}
r = fd_wait_for_event(v->fd, POLLOUT, USEC_INFINITY);
if (r < 0) {
if (ERRNO_IS_TRANSIENT(r))
continue;
if (ERRNO_IS_NEG_TRANSIENT(r))
continue;
if (r < 0)
return varlink_log_errno(v, r, "Poll failed on fd: %m");
}
assert(r != 0);
assert(r > 0);
handle_revents(v, r);
}