diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-12-19 13:20:30 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2022-12-19 15:00:59 +0100 |
commit | 3401477982d09e0c9815ae5a69e56f43f187967e (patch) | |
tree | fdf3ce225df76b9e643835928dc29aeef02a51fc /src/core | |
parent | a5937dcf3902ecb90777f259f6e006292eb54251 (diff) | |
download | systemd-3401477982d09e0c9815ae5a69e56f43f187967e.tar.gz |
tree-wide: use -EBADF also in pipe initializers
In some places, initialization is dropped when unnecesary.
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/automount.c | 16 | ||||
-rw-r--r-- | src/core/dynamic-user.c | 2 | ||||
-rw-r--r-- | src/core/execute.c | 8 | ||||
-rw-r--r-- | src/core/service.c | 2 | ||||
-rw-r--r-- | src/core/socket.c | 4 |
5 files changed, 16 insertions, 16 deletions
diff --git a/src/core/automount.c b/src/core/automount.c index d2976d6734..361034d7f4 100644 --- a/src/core/automount.c +++ b/src/core/automount.c @@ -573,7 +573,7 @@ static void automount_trigger_notify(Unit *u, Unit *other) { static void automount_enter_waiting(Automount *a) { _cleanup_close_ int ioctl_fd = -EBADF; - int p[2] = { -1, -1 }; + int pipe_fd[2] = { -EBADF, -EBADF }; char name[STRLEN("systemd-") + DECIMAL_STR_MAX(pid_t) + 1]; _cleanup_free_ char *options = NULL; bool mounted = false; @@ -600,18 +600,18 @@ static void automount_enter_waiting(Automount *a) { goto fail; } - if (pipe2(p, O_CLOEXEC) < 0) { + if (pipe2(pipe_fd, O_CLOEXEC) < 0) { r = -errno; goto fail; } - r = fd_nonblock(p[0], true); + r = fd_nonblock(pipe_fd[0], true); if (r < 0) goto fail; if (asprintf( &options, "fd=%i,pgrp="PID_FMT",minproto=5,maxproto=5,direct%s%s", - p[1], + pipe_fd[1], getpgrp(), isempty(a->extra_options) ? "" : ",", strempty(a->extra_options)) < 0) { @@ -626,7 +626,7 @@ static void automount_enter_waiting(Automount *a) { mounted = true; - p[1] = safe_close(p[1]); + pipe_fd[1] = safe_close(pipe_fd[1]); if (stat(a->where, &st) < 0) { r = -errno; @@ -647,13 +647,13 @@ static void automount_enter_waiting(Automount *a) { if (r < 0) goto fail; - r = sd_event_add_io(UNIT(a)->manager->event, &a->pipe_event_source, p[0], EPOLLIN, automount_dispatch_io, a); + r = sd_event_add_io(UNIT(a)->manager->event, &a->pipe_event_source, pipe_fd[0], EPOLLIN, automount_dispatch_io, a); if (r < 0) goto fail; (void) sd_event_source_set_description(a->pipe_event_source, "automount-io"); - a->pipe_fd = p[0]; + a->pipe_fd = pipe_fd[0]; a->dev_id = st.st_dev; automount_set_state(a, AUTOMOUNT_WAITING); @@ -663,7 +663,7 @@ static void automount_enter_waiting(Automount *a) { fail: log_unit_error_errno(UNIT(a), r, "Failed to initialize automounter: %m"); - safe_close_pair(p); + safe_close_pair(pipe_fd); if (mounted) { r = repeat_unmount(a->where, MNT_DETACH|UMOUNT_NOFOLLOW); diff --git a/src/core/dynamic-user.c b/src/core/dynamic-user.c index e0b371a4c4..763f5d4c84 100644 --- a/src/core/dynamic-user.c +++ b/src/core/dynamic-user.c @@ -74,7 +74,7 @@ static int dynamic_user_add(Manager *m, const char *name, int storage_socket[sta } static int dynamic_user_acquire(Manager *m, const char *name, DynamicUser** ret) { - _cleanup_close_pair_ int storage_socket[2] = { -1, -1 }; + _cleanup_close_pair_ int storage_socket[2] = { -EBADF, -EBADF }; DynamicUser *d; int r; diff --git a/src/core/execute.c b/src/core/execute.c index 94021f20e8..5784c8ce5c 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -2099,7 +2099,7 @@ bool exec_needs_mount_namespace( static int setup_private_users(uid_t ouid, gid_t ogid, uid_t uid, gid_t gid) { _cleanup_free_ char *uid_map = NULL, *gid_map = NULL; - _cleanup_close_pair_ int errno_pipe[2] = { -1, -1 }; + _cleanup_close_pair_ int errno_pipe[2] = { -EBADF, -EBADF }; _cleanup_close_ int unshare_ready_fd = -EBADF; _cleanup_(sigkill_waitp) pid_t pid = 0; uint64_t c = 1; @@ -6609,8 +6609,8 @@ static int exec_runtime_allocate(ExecRuntime **ret, const char *id) { *n = (ExecRuntime) { .id = TAKE_PTR(id_copy), - .netns_storage_socket = { -1, -1 }, - .ipcns_storage_socket = { -1, -1 }, + .netns_storage_socket = { -EBADF, -EBADF }, + .ipcns_storage_socket = { -EBADF, -EBADF }, }; *ret = n; @@ -6672,7 +6672,7 @@ static int exec_runtime_make( ExecRuntime **ret) { _cleanup_(namespace_cleanup_tmpdirp) char *tmp_dir = NULL, *var_tmp_dir = NULL; - _cleanup_close_pair_ int netns_storage_socket[2] = { -1, -1 }, ipcns_storage_socket[2] = { -1, -1 }; + _cleanup_close_pair_ int netns_storage_socket[2] = { -EBADF, -EBADF }, ipcns_storage_socket[2] = { -EBADF, -EBADF }; int r; assert(m); diff --git a/src/core/service.c b/src/core/service.c index 5181826c84..c967dc9897 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -1402,7 +1402,7 @@ static int service_allocate_exec_fd( sd_event_source **ret_event_source, int *ret_exec_fd) { - _cleanup_close_pair_ int p[] = { -1, -1 }; + _cleanup_close_pair_ int p[] = { -EBADF, -EBADF }; int r; assert(s); diff --git a/src/core/socket.c b/src/core/socket.c index e0e91dba53..518f277053 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -1502,7 +1502,7 @@ static int socket_address_listen_in_cgroup( const SocketAddress *address, const char *label) { - _cleanup_close_pair_ int pair[2] = { -1, -1 }; + _cleanup_close_pair_ int pair[2] = { -EBADF, -EBADF }; int fd, r; pid_t pid; @@ -2899,7 +2899,7 @@ static int socket_accept_do(Socket *s, int fd) { } static int socket_accept_in_cgroup(Socket *s, SocketPort *p, int fd) { - _cleanup_close_pair_ int pair[2] = { -1, -1 }; + _cleanup_close_pair_ int pair[2] = { -EBADF, -EBADF }; int cfd, r; pid_t pid; |