|
|
2aacef |
From f0c8da5396c02e2a935e9e8de1e8c08956feb672 Mon Sep 17 00:00:00 2001
|
|
|
2aacef |
From: Lennart Poettering <lennart@poettering.net>
|
|
|
2aacef |
Date: Tue, 22 Nov 2022 12:14:33 +0100
|
|
|
2aacef |
Subject: [PATCH] tree-wide: modernizations with RET_NERRNO()
|
|
|
2aacef |
|
|
|
2aacef |
(cherry picked from commit 108dfff2c7aebadb78e485ed564caf559367bf7c)
|
|
|
2aacef |
|
|
|
2aacef |
Related: #2137584
|
|
|
2aacef |
---
|
|
|
2aacef |
src/shared/ask-password-api.c | 30 +++++++++++++-----------------
|
|
|
2aacef |
src/shared/barrier.c | 4 +---
|
|
|
2aacef |
2 files changed, 14 insertions(+), 20 deletions(-)
|
|
|
2aacef |
|
|
|
2aacef |
diff --git a/src/shared/ask-password-api.c b/src/shared/ask-password-api.c
|
|
|
2aacef |
index 17474fe0be..871af2ec99 100644
|
|
|
2aacef |
--- a/src/shared/ask-password-api.c
|
|
|
2aacef |
+++ b/src/shared/ask-password-api.c
|
|
|
2aacef |
@@ -230,8 +230,7 @@ int ask_password_plymouth(
|
|
|
2aacef |
if (notify < 0)
|
|
|
2aacef |
return -errno;
|
|
|
2aacef |
|
|
|
2aacef |
- r = inotify_add_watch(notify, flag_file, IN_ATTRIB); /* for the link count */
|
|
|
2aacef |
- if (r < 0)
|
|
|
2aacef |
+ if (inotify_add_watch(notify, flag_file, IN_ATTRIB) < 0) /* for the link count */
|
|
|
2aacef |
return -errno;
|
|
|
2aacef |
}
|
|
|
2aacef |
|
|
|
2aacef |
@@ -239,8 +238,7 @@ int ask_password_plymouth(
|
|
|
2aacef |
if (fd < 0)
|
|
|
2aacef |
return -errno;
|
|
|
2aacef |
|
|
|
2aacef |
- r = connect(fd, &sa.sa, SOCKADDR_UN_LEN(sa.un));
|
|
|
2aacef |
- if (r < 0)
|
|
|
2aacef |
+ if (connect(fd, &sa.sa, SOCKADDR_UN_LEN(sa.un)) < 0)
|
|
|
2aacef |
return -errno;
|
|
|
2aacef |
|
|
|
2aacef |
if (FLAGS_SET(flags, ASK_PASSWORD_ACCEPT_CACHED)) {
|
|
|
2aacef |
@@ -464,10 +462,9 @@ int ask_password_tty(
|
|
|
2aacef |
new_termios.c_cc[VMIN] = 1;
|
|
|
2aacef |
new_termios.c_cc[VTIME] = 0;
|
|
|
2aacef |
|
|
|
2aacef |
- if (tcsetattr(ttyfd, TCSADRAIN, &new_termios) < 0) {
|
|
|
2aacef |
- r = -errno;
|
|
|
2aacef |
+ r = RET_NERRNO(tcsetattr(ttyfd, TCSADRAIN, &new_termios));
|
|
|
2aacef |
+ if (r < 0)
|
|
|
2aacef |
goto finish;
|
|
|
2aacef |
- }
|
|
|
2aacef |
|
|
|
2aacef |
reset_tty = true;
|
|
|
2aacef |
}
|
|
|
2aacef |
@@ -491,11 +488,11 @@ int ask_password_tty(
|
|
|
2aacef |
else
|
|
|
2aacef |
timeout = USEC_INFINITY;
|
|
|
2aacef |
|
|
|
2aacef |
- if (flag_file)
|
|
|
2aacef |
- if (access(flag_file, F_OK) < 0) {
|
|
|
2aacef |
- r = -errno;
|
|
|
2aacef |
+ if (flag_file) {
|
|
|
2aacef |
+ r = RET_NERRNO(access(flag_file, F_OK));
|
|
|
2aacef |
+ if (r < 0)
|
|
|
2aacef |
goto finish;
|
|
|
2aacef |
- }
|
|
|
2aacef |
+ }
|
|
|
2aacef |
|
|
|
2aacef |
r = ppoll_usec(pollfd, notify >= 0 ? 2 : 1, timeout);
|
|
|
2aacef |
if (r == -EINTR)
|
|
|
2aacef |
@@ -747,10 +744,10 @@ int ask_password_agent(
|
|
|
2aacef |
r = -errno;
|
|
|
2aacef |
goto finish;
|
|
|
2aacef |
}
|
|
|
2aacef |
- if (inotify_add_watch(notify, "/run/systemd/ask-password", IN_ATTRIB /* for mtime */) < 0) {
|
|
|
2aacef |
- r = -errno;
|
|
|
2aacef |
+
|
|
|
2aacef |
+ r = RET_NERRNO(inotify_add_watch(notify, "/run/systemd/ask-password", IN_ATTRIB /* for mtime */));
|
|
|
2aacef |
+ if (r < 0)
|
|
|
2aacef |
goto finish;
|
|
|
2aacef |
- }
|
|
|
2aacef |
}
|
|
|
2aacef |
|
|
|
2aacef |
fd = mkostemp_safe(temp);
|
|
|
2aacef |
@@ -813,10 +810,9 @@ int ask_password_agent(
|
|
|
2aacef |
final[sizeof(final)-10] = 's';
|
|
|
2aacef |
final[sizeof(final)-9] = 'k';
|
|
|
2aacef |
|
|
|
2aacef |
- if (rename(temp, final) < 0) {
|
|
|
2aacef |
- r = -errno;
|
|
|
2aacef |
+ r = RET_NERRNO(rename(temp, final));
|
|
|
2aacef |
+ if (r < 0)
|
|
|
2aacef |
goto finish;
|
|
|
2aacef |
- }
|
|
|
2aacef |
|
|
|
2aacef |
zero(pollfd);
|
|
|
2aacef |
pollfd[FD_SOCKET].fd = socket_fd;
|
|
|
2aacef |
diff --git a/src/shared/barrier.c b/src/shared/barrier.c
|
|
|
2aacef |
index cbe54a60cd..d76a61a5db 100644
|
|
|
2aacef |
--- a/src/shared/barrier.c
|
|
|
2aacef |
+++ b/src/shared/barrier.c
|
|
|
2aacef |
@@ -92,7 +92,6 @@
|
|
|
2aacef |
*/
|
|
|
2aacef |
int barrier_create(Barrier *b) {
|
|
|
2aacef |
_unused_ _cleanup_(barrier_destroyp) Barrier *staging = b;
|
|
|
2aacef |
- int r;
|
|
|
2aacef |
|
|
|
2aacef |
assert(b);
|
|
|
2aacef |
|
|
|
2aacef |
@@ -104,8 +103,7 @@ int barrier_create(Barrier *b) {
|
|
|
2aacef |
if (b->them < 0)
|
|
|
2aacef |
return -errno;
|
|
|
2aacef |
|
|
|
2aacef |
- r = pipe2(b->pipe, O_CLOEXEC | O_NONBLOCK);
|
|
|
2aacef |
- if (r < 0)
|
|
|
2aacef |
+ if (pipe2(b->pipe, O_CLOEXEC | O_NONBLOCK) < 0)
|
|
|
2aacef |
return -errno;
|
|
|
2aacef |
|
|
|
2aacef |
staging = NULL;
|