diff options
author | Mike Yuan <me@yhndnzj.com> | 2023-11-23 13:38:29 +0100 |
---|---|---|
committer | Mike Yuan <me@yhndnzj.com> | 2023-11-23 13:42:44 +0100 |
commit | 9e743e7ea93efea2e20eab38d5bf51948336887d (patch) | |
tree | ee85946fc4bdb32cc59302b4cc912ef2beaa3474 /src | |
parent | core/manager: rename result parameter to ret (diff) | |
download | systemd-9e743e7ea93efea2e20eab38d5bf51948336887d.tar.xz systemd-9e743e7ea93efea2e20eab38d5bf51948336887d.zip |
core/manager: correct and simplify errno handling
open_parent() is our own function that returns negative errno.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/manager.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/core/manager.c b/src/core/manager.c index 8c8a25826e..dadfc51369 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -1032,23 +1032,23 @@ int manager_new(RuntimeScope runtime_scope, ManagerTestRunFlags test_run_flags, self_dir_fd = open_parent(self_exe, O_CLOEXEC|O_DIRECTORY, 0); if (self_dir_fd < 0) - return -errno; + return self_dir_fd; - m->executor_fd = openat(self_dir_fd, "systemd-executor", O_CLOEXEC|O_PATH); - if (m->executor_fd < 0 && errno == ENOENT) - m->executor_fd = openat(AT_FDCWD, "systemd-executor", O_CLOEXEC|O_PATH); - if (m->executor_fd < 0 && errno == ENOENT) { - m->executor_fd = open(SYSTEMD_EXECUTOR_BINARY_PATH, O_CLOEXEC|O_PATH); + m->executor_fd = RET_NERRNO(openat(self_dir_fd, "systemd-executor", O_CLOEXEC|O_PATH)); + if (m->executor_fd == -ENOENT) + m->executor_fd = RET_NERRNO(openat(AT_FDCWD, "systemd-executor", O_CLOEXEC|O_PATH)); + if (m->executor_fd == -ENOENT) { + m->executor_fd = RET_NERRNO(open(SYSTEMD_EXECUTOR_BINARY_PATH, O_CLOEXEC|O_PATH)); level = LOG_WARNING; /* Tests should normally use local builds */ } if (m->executor_fd < 0) - return -errno; + return m->executor_fd; r = fd_get_path(m->executor_fd, &executor_path); if (r < 0) return r; - log_full(level, "Using systemd-executor binary from '%s'", executor_path); + log_full(level, "Using systemd-executor binary from '%s'.", executor_path); } /* Note that we do not set up the notify fd here. We do that after deserialization, |