summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2022-12-20 19:01:54 +0100
committerGitHub <noreply@github.com>2022-12-20 19:01:54 +0100
commit5948d654fa0fe6122f09e0f3df3ea340d4b0a87e (patch)
treed70de8b2220d30e0d28002fc6b070a291ede967e /src
parentb7641425659243c09473cd8fb3aef2c0d4a3eb9c (diff)
parent5bb1d7fbab469b350d132cbbd2c794ffacef1b81 (diff)
downloadsystemd-5948d654fa0fe6122f09e0f3df3ea340d4b0a87e.tar.gz
Merge pull request #25789 from yuwata/EBADF
tree-wide: use -EBADF more
Diffstat (limited to 'src')
-rw-r--r--src/basic/async.c2
-rw-r--r--src/basic/chase-symlinks.c2
-rw-r--r--src/basic/fd-util.c2
-rw-r--r--src/basic/fd-util.h7
-rw-r--r--src/basic/fileio.c2
-rw-r--r--src/basic/terminal-util.c4
-rw-r--r--src/cgroups-agent/cgroups-agent.c2
-rw-r--r--src/core/automount.c2
-rw-r--r--src/core/dynamic-user.c10
-rw-r--r--src/core/execute.c8
-rw-r--r--src/core/manager.c2
-rw-r--r--src/core/namespace.c4
-rw-r--r--src/core/service.c2
-rw-r--r--src/core/socket.c4
-rw-r--r--src/coredump/coredump.c2
-rw-r--r--src/firstboot/firstboot.c2
-rw-r--r--src/fsck/fsck.c2
-rw-r--r--src/fuzz/fuzz-varlink.c2
-rw-r--r--src/import/import-common.c8
-rw-r--r--src/import/importd.c2
-rw-r--r--src/import/pull-common.c6
-rw-r--r--src/initctl/initctl.c2
-rw-r--r--src/journal/fuzz-journald-stream.c2
-rw-r--r--src/libsystemd-network/arp-util.c2
-rw-r--r--src/libsystemd-network/dhcp-network.c4
-rw-r--r--src/libsystemd-network/dhcp6-network.c2
-rw-r--r--src/libsystemd-network/fuzz-dhcp6-client.c2
-rw-r--r--src/libsystemd-network/fuzz-lldp-rx.c2
-rw-r--r--src/libsystemd-network/fuzz-ndisc-rs.c10
-rw-r--r--src/libsystemd-network/icmp6-util.c2
-rw-r--r--src/libsystemd-network/test-dhcp6-client.c2
-rw-r--r--src/libsystemd-network/test-lldp-rx.c2
-rw-r--r--src/libsystemd/sd-bus/bus-container.c2
-rw-r--r--src/libsystemd/sd-bus/test-bus-benchmark.c4
-rw-r--r--src/libsystemd/sd-bus/test-bus-chat.c2
-rw-r--r--src/libsystemd/sd-daemon/sd-daemon.c2
-rw-r--r--src/libsystemd/sd-device/device-monitor.c4
-rw-r--r--src/libsystemd/sd-event/sd-event.c2
-rw-r--r--src/libsystemd/sd-event/test-event.c6
-rw-r--r--src/libsystemd/sd-login/test-login.c2
-rw-r--r--src/machine/image-dbus.c4
-rw-r--r--src/machine/machine-dbus.c14
-rw-r--r--src/machine/machined-dbus.c2
-rw-r--r--src/nspawn/nspawn-setuid.c2
-rw-r--r--src/nspawn/nspawn.c14
-rw-r--r--src/portable/portable.c2
-rw-r--r--src/portable/portabled-image-bus.c2
-rw-r--r--src/resolve/resolved-llmnr.c8
-rw-r--r--src/resolve/resolved-mdns.c4
-rw-r--r--src/rfkill/rfkill.c2
-rw-r--r--src/run/run.c2
-rw-r--r--src/shared/copy.c2
-rw-r--r--src/shared/data-fd-util.c4
-rw-r--r--src/shared/dissect-image.c2
-rw-r--r--src/shared/elf-util.c6
-rw-r--r--src/shared/logs-show.c2
-rw-r--r--src/shared/loop-util.c2
-rw-r--r--src/shared/mount-util.c2
-rw-r--r--src/shared/pager.c2
-rw-r--r--src/socket-proxy/socket-proxyd.c4
-rw-r--r--src/sysupdate/sysupdate-resource.c4
-rw-r--r--src/sysusers/sysusers.c4
-rw-r--r--src/test/test-compress.c2
-rw-r--r--src/test/test-copy.c4
-rw-r--r--src/test/test-data-fd-util.c2
-rw-r--r--src/test/test-execute.c4
-rw-r--r--src/test/test-fd-util.c6
-rw-r--r--src/test/test-fileio.c2
-rw-r--r--src/test/test-namespace.c2
-rw-r--r--src/test/test-terminal-util.c2
-rw-r--r--src/test/test-varlink.c2
-rw-r--r--src/timesync/timesyncd-manager.c2
-rw-r--r--src/tty-ask-password-agent/tty-ask-password-agent.c2
-rw-r--r--src/udev/udev-ctrl.c6
-rw-r--r--src/udev/udev-event.c4
-rw-r--r--src/udev/udevd.c2
76 files changed, 134 insertions, 131 deletions
diff --git a/src/basic/async.c b/src/basic/async.c
index 241803f33a..73de889a2b 100644
--- a/src/basic/async.c
+++ b/src/basic/async.c
@@ -103,5 +103,5 @@ int asynchronous_close(int fd) {
assert_se(close_nointr(fd) != -EBADF);
}
- return -1;
+ return -EBADF;
}
diff --git a/src/basic/chase-symlinks.c b/src/basic/chase-symlinks.c
index a9de17b476..a0134fd330 100644
--- a/src/basic/chase-symlinks.c
+++ b/src/basic/chase-symlinks.c
@@ -206,7 +206,7 @@ int chase_symlinks_at(
for (todo = buffer;;) {
_cleanup_free_ char *first = NULL;
- _cleanup_close_ int child = -1;
+ _cleanup_close_ int child = -EBADF;
struct stat st;
const char *e;
diff --git a/src/basic/fd-util.c b/src/basic/fd-util.c
index 8879b998ca..4d6d01cd99 100644
--- a/src/basic/fd-util.c
+++ b/src/basic/fd-util.c
@@ -246,7 +246,7 @@ static int close_all_fds_frugal(const int except[], size_t n_except) {
"Refusing to loop over %d potential fds.",
max_fd);
- for (int fd = 3; fd >= 0; fd = fd < max_fd ? fd + 1 : -1) {
+ for (int fd = 3; fd >= 0; fd = fd < max_fd ? fd + 1 : -EBADF) {
int q;
if (fd_in_set(fd, except, n_except))
diff --git a/src/basic/fd-util.h b/src/basic/fd-util.h
index 530270a73f..97339254ba 100644
--- a/src/basic/fd-util.h
+++ b/src/basic/fd-util.h
@@ -15,14 +15,15 @@
/* Make sure we can distinguish fd 0 and NULL */
#define FD_TO_PTR(fd) INT_TO_PTR((fd)+1)
#define PTR_TO_FD(p) (PTR_TO_INT(p)-1)
+#define PIPE_EBADF { -EBADF, -EBADF }
int close_nointr(int fd);
int safe_close(int fd);
void safe_close_pair(int p[static 2]);
static inline int safe_close_above_stdio(int fd) {
- if (fd < 3) /* Don't close stdin/stdout/stderr, but still invalidate the fd by returning -1 */
- return -1;
+ if (fd < 3) /* Don't close stdin/stdout/stderr, but still invalidate the fd by returning -EBADF. */
+ return -EBADF;
return safe_close(fd);
}
@@ -86,7 +87,7 @@ int fd_move_above_stdio(int fd);
int rearrange_stdio(int original_input_fd, int original_output_fd, int original_error_fd);
static inline int make_null_stdio(void) {
- return rearrange_stdio(-1, -1, -1);
+ return rearrange_stdio(-EBADF, -EBADF, -EBADF);
}
/* Like TAKE_PTR() but for file descriptors, resetting them to -1 */
diff --git a/src/basic/fileio.c b/src/basic/fileio.c
index a901597962..0937e58a15 100644
--- a/src/basic/fileio.c
+++ b/src/basic/fileio.c
@@ -767,7 +767,7 @@ int read_full_file_full(
r = xfopenat(dir_fd, filename, "re", 0, &f);
if (r < 0) {
- _cleanup_close_ int sk = -1;
+ _cleanup_close_ int sk = -EBADF;
/* ENXIO is what Linux returns if we open a node that is an AF_UNIX socket */
if (r != -ENXIO)
diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c
index 6afcf066cd..5cf2055dc6 100644
--- a/src/basic/terminal-util.c
+++ b/src/basic/terminal-util.c
@@ -1130,7 +1130,7 @@ static int ptsname_namespace(int pty, char **ret) {
int openpt_allocate_in_namespace(pid_t pid, int flags, char **ret_slave) {
_cleanup_close_ int pidnsfd = -EBADF, mntnsfd = -EBADF, usernsfd = -EBADF, rootfd = -EBADF, fd = -EBADF;
- _cleanup_close_pair_ int pair[2] = { -EBADF, -EBADF };
+ _cleanup_close_pair_ int pair[2] = PIPE_EBADF;
pid_t child;
int r;
@@ -1183,7 +1183,7 @@ int openpt_allocate_in_namespace(pid_t pid, int flags, char **ret_slave) {
int open_terminal_in_namespace(pid_t pid, const char *name, int mode) {
_cleanup_close_ int pidnsfd = -EBADF, mntnsfd = -EBADF, usernsfd = -EBADF, rootfd = -EBADF;
- _cleanup_close_pair_ int pair[2] = { -EBADF, -EBADF };
+ _cleanup_close_pair_ int pair[2] = PIPE_EBADF;
pid_t child;
int r;
diff --git a/src/cgroups-agent/cgroups-agent.c b/src/cgroups-agent/cgroups-agent.c
index d6480097b5..16c5a2a693 100644
--- a/src/cgroups-agent/cgroups-agent.c
+++ b/src/cgroups-agent/cgroups-agent.c
@@ -18,7 +18,7 @@ int main(int argc, char *argv[]) {
size_t l;
int r;
- r = rearrange_stdio(-1, -1, -1);
+ r = make_null_stdio();
if (r < 0) {
log_error_errno(r, "Failed to connect stdin/stdout/stderr with /dev/null: %m");
return EXIT_FAILURE;
diff --git a/src/core/automount.c b/src/core/automount.c
index 361034d7f4..4cffca419c 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 pipe_fd[2] = { -EBADF, -EBADF };
+ int pipe_fd[2] = PIPE_EBADF;
char name[STRLEN("systemd-") + DECIMAL_STR_MAX(pid_t) + 1];
_cleanup_free_ char *options = NULL;
bool mounted = false;
diff --git a/src/core/dynamic-user.c b/src/core/dynamic-user.c
index 763f5d4c84..c756c1c524 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] = { -EBADF, -EBADF };
+ _cleanup_close_pair_ int storage_socket[2] = PIPE_EBADF;
DynamicUser *d;
int r;
@@ -127,7 +127,7 @@ static int dynamic_user_acquire(Manager *m, const char *name, DynamicUser** ret)
if (r < 0)
return r;
- storage_socket[0] = storage_socket[1] = -1;
+ storage_socket[0] = storage_socket[1] = -EBADF;
if (ret) {
d->n_ref++;
@@ -382,7 +382,7 @@ static int dynamic_user_realize(
uid_t *ret_uid, gid_t *ret_gid,
bool is_user) {
- _cleanup_(unlockfp) int storage_socket0_lock = -1;
+ _cleanup_(unlockfp) int storage_socket0_lock = -EBADF;
_cleanup_close_ int uid_lock_fd = -EBADF;
_cleanup_close_ int etc_passwd_lock_fd = -EBADF;
uid_t num = UID_INVALID; /* a uid if is_user, and a gid otherwise */
@@ -524,7 +524,7 @@ static int dynamic_user_realize(
}
int dynamic_user_current(DynamicUser *d, uid_t *ret) {
- _cleanup_(unlockfp) int storage_socket0_lock = -1;
+ _cleanup_(unlockfp) int storage_socket0_lock = -EBADF;
_cleanup_close_ int lock_fd = -EBADF;
uid_t uid;
int r;
@@ -567,7 +567,7 @@ static DynamicUser* dynamic_user_unref(DynamicUser *d) {
}
static int dynamic_user_close(DynamicUser *d) {
- _cleanup_(unlockfp) int storage_socket0_lock = -1;
+ _cleanup_(unlockfp) int storage_socket0_lock = -EBADF;
_cleanup_close_ int lock_fd = -EBADF;
uid_t uid;
int r;
diff --git a/src/core/execute.c b/src/core/execute.c
index 5784c8ce5c..5dc8535a47 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] = { -EBADF, -EBADF };
+ _cleanup_close_pair_ int errno_pipe[2] = PIPE_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 = { -EBADF, -EBADF },
- .ipcns_storage_socket = { -EBADF, -EBADF },
+ .netns_storage_socket = PIPE_EBADF,
+ .ipcns_storage_socket = PIPE_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] = { -EBADF, -EBADF }, ipcns_storage_socket[2] = { -EBADF, -EBADF };
+ _cleanup_close_pair_ int netns_storage_socket[2] = PIPE_EBADF, ipcns_storage_socket[2] = PIPE_EBADF;
int r;
assert(m);
diff --git a/src/core/manager.c b/src/core/manager.c
index 4e15f5cb8b..3332d5775b 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -851,7 +851,7 @@ int manager_new(LookupScope scope, ManagerTestRunFlags test_run_flags, Manager *
.notify_fd = -EBADF,
.cgroups_agent_fd = -EBADF,
.signal_fd = -EBADF,
- .user_lookup_fds = { -EBADF, -EBADF },
+ .user_lookup_fds = PIPE_EBADF,
.private_listen_fd = -EBADF,
.dev_autofs_fd = -EBADF,
.cgroup_inotify_fd = -EBADF,
diff --git a/src/core/namespace.c b/src/core/namespace.c
index d7c911a509..d46daa3c05 100644
--- a/src/core/namespace.c
+++ b/src/core/namespace.c
@@ -2832,7 +2832,7 @@ int setup_tmp_dirs(const char *id, char **tmp_dir, char **var_tmp_dir) {
}
int setup_shareable_ns(const int ns_storage_socket[static 2], unsigned long nsflag) {
- _cleanup_close_ int ns = -1;
+ _cleanup_close_ int ns = -EBADF;
int r, q;
const char *ns_name, *ns_path;
@@ -2900,7 +2900,7 @@ fail:
}
int open_shareable_ns_path(const int ns_storage_socket[static 2], const char *path, unsigned long nsflag) {
- _cleanup_close_ int ns = -1;
+ _cleanup_close_ int ns = -EBADF;
int q, r;
assert(ns_storage_socket);
diff --git a/src/core/service.c b/src/core/service.c
index c967dc9897..b1fe19127f 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[] = { -EBADF, -EBADF };
+ _cleanup_close_pair_ int p[] = PIPE_EBADF;
int r;
assert(s);
diff --git a/src/core/socket.c b/src/core/socket.c
index 518f277053..409d415d8d 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] = { -EBADF, -EBADF };
+ _cleanup_close_pair_ int pair[2] = PIPE_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] = { -EBADF, -EBADF };
+ _cleanup_close_pair_ int pair[2] = PIPE_EBADF;
int cfd, r;
pid_t pid;
diff --git a/src/coredump/coredump.c b/src/coredump/coredump.c
index c8c8158eef..192dc4c654 100644
--- a/src/coredump/coredump.c
+++ b/src/coredump/coredump.c
@@ -1463,7 +1463,7 @@ static int process_kernel(int argc, char* argv[]) {
/* When we're invoked by the kernel, stdout/stderr are closed which is dangerous because the fds
* could get reallocated. To avoid hard to debug issues, let's instead bind stdout/stderr to
* /dev/null. */
- r = rearrange_stdio(STDIN_FILENO, -1, -1);
+ r = rearrange_stdio(STDIN_FILENO, -EBADF, -EBADF);
if (r < 0)
return log_error_errno(r, "Failed to connect stdout/stderr to /dev/null: %m");
diff --git a/src/firstboot/firstboot.c b/src/firstboot/firstboot.c
index 7cd9aed579..651415568d 100644
--- a/src/firstboot/firstboot.c
+++ b/src/firstboot/firstboot.c
@@ -881,7 +881,7 @@ static int write_root_shadow(const char *shadow_path, const char *hashed_passwor
}
static int process_root_account(void) {
- _cleanup_close_ int lock = -1;
+ _cleanup_close_ int lock = -EBADF;
_cleanup_(erase_and_freep) char *_hashed_password = NULL;
const char *password, *hashed_password;
const char *etc_passwd, *etc_shadow;
diff --git a/src/fsck/fsck.c b/src/fsck/fsck.c
index 29265d9220..37fdfa540f 100644
--- a/src/fsck/fsck.c
+++ b/src/fsck/fsck.c
@@ -241,7 +241,7 @@ static int fsck_progress_socket(void) {
}
static int run(int argc, char *argv[]) {
- _cleanup_close_pair_ int progress_pipe[2] = { -EBADF, -EBADF };
+ _cleanup_close_pair_ int progress_pipe[2] = PIPE_EBADF;
_cleanup_(sd_device_unrefp) sd_device *dev = NULL;
_cleanup_free_ char *dpath = NULL;
_cleanup_fclose_ FILE *console = NULL;
diff --git a/src/fuzz/fuzz-varlink.c b/src/fuzz/fuzz-varlink.c
index c97586be9e..cbfde088d9 100644
--- a/src/fuzz/fuzz-varlink.c
+++ b/src/fuzz/fuzz-varlink.c
@@ -85,7 +85,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
struct iovec server_iov = IOVEC_MAKE((void*) data, size), client_iov = IOVEC_MAKE((void*) data, size);
/* Important: the declaration order matters here! we want that the fds are closed on return after the
* event sources, hence we declare the fds first, the event sources second */
- _cleanup_close_pair_ int server_pair[2] = { -EBADF, -EBADF }, client_pair[2] = { -EBADF, -EBADF };
+ _cleanup_close_pair_ int server_pair[2] = PIPE_EBADF, client_pair[2] = PIPE_EBADF;
_cleanup_(sd_event_source_unrefp) sd_event_source *idle_event_source = NULL,
*server_event_source = NULL, *client_event_source = NULL;
_cleanup_(varlink_server_unrefp) VarlinkServer *s = NULL;
diff --git a/src/import/import-common.c b/src/import/import-common.c
index eb52c6c116..0e2c7edae1 100644
--- a/src/import/import-common.c
+++ b/src/import/import-common.c
@@ -23,7 +23,7 @@
#include "tmpfile-util.h"
int import_fork_tar_x(const char *path, pid_t *ret) {
- _cleanup_close_pair_ int pipefd[2] = { -EBADF, -EBADF };
+ _cleanup_close_pair_ int pipefd[2] = PIPE_EBADF;
bool use_selinux;
pid_t pid;
int r;
@@ -64,7 +64,7 @@ int import_fork_tar_x(const char *path, pid_t *ret) {
pipefd[1] = safe_close(pipefd[1]);
- r = rearrange_stdio(TAKE_FD(pipefd[0]), -1, STDERR_FILENO);
+ r = rearrange_stdio(TAKE_FD(pipefd[0]), -EBADF, STDERR_FILENO);
if (r < 0) {
log_error_errno(r, "Failed to rearrange stdin/stdout: %m");
_exit(EXIT_FAILURE);
@@ -96,7 +96,7 @@ int import_fork_tar_x(const char *path, pid_t *ret) {
}
int import_fork_tar_c(const char *path, pid_t *ret) {
- _cleanup_close_pair_ int pipefd[2] = { -EBADF, -EBADF };
+ _cleanup_close_pair_ int pipefd[2] = PIPE_EBADF;
bool use_selinux;
pid_t pid;
int r;
@@ -130,7 +130,7 @@ int import_fork_tar_c(const char *path, pid_t *ret) {
pipefd[0] = safe_close(pipefd[0]);
- r = rearrange_stdio(-1, TAKE_FD(pipefd[1]), STDERR_FILENO);
+ r = rearrange_stdio(-EBADF, TAKE_FD(pipefd[1]), STDERR_FILENO);
if (r < 0) {
log_error_errno(r, "Failed to rearrange stdin/stdout: %m");
_exit(EXIT_FAILURE);
diff --git a/src/import/importd.c b/src/import/importd.c
index b6d90cde10..65647a66a6 100644
--- a/src/import/importd.c
+++ b/src/import/importd.c
@@ -356,7 +356,7 @@ static int transfer_on_log(sd_event_source *s, int fd, uint32_t revents, void *u
}
static int transfer_start(Transfer *t) {
- _cleanup_close_pair_ int pipefd[2] = { -EBADF, -EBADF };
+ _cleanup_close_pair_ int pipefd[2] = PIPE_EBADF;
int r;
assert(t);
diff --git a/src/import/pull-common.c b/src/import/pull-common.c
index 1c7194fd6b..6980f12a79 100644
--- a/src/import/pull-common.c
+++ b/src/import/pull-common.c
@@ -381,7 +381,7 @@ static int verify_gpg(
const void *payload, size_t payload_size,
const void *signature, size_t signature_size) {
- _cleanup_close_pair_ int gpg_pipe[2] = { -EBADF, -EBADF };
+ _cleanup_close_pair_ int gpg_pipe[2] = PIPE_EBADF;
char sig_file_path[] = "/tmp/sigXXXXXX", gpg_home[] = "/tmp/gpghomeXXXXXX";
_cleanup_(sigkill_waitp) pid_t pid = 0;
bool gpg_home_created = false;
@@ -395,7 +395,7 @@ static int verify_gpg(
return log_error_errno(errno, "Failed to create pipe for gpg: %m");
if (signature_size > 0) {
- _cleanup_close_ int sig_file = -1;
+ _cleanup_close_ int sig_file = -EBADF;
sig_file = mkostemp(sig_file_path, O_RDWR);
if (sig_file < 0)
@@ -440,7 +440,7 @@ static int verify_gpg(
gpg_pipe[1] = safe_close(gpg_pipe[1]);
- r = rearrange_stdio(TAKE_FD(gpg_pipe[0]), -1, STDERR_FILENO);
+ r = rearrange_stdio(TAKE_FD(gpg_pipe[0]), -EBADF, STDERR_FILENO);
if (r < 0) {
log_error_errno(r, "Failed to rearrange stdin/stdout: %m");
_exit(EXIT_FAILURE);
diff --git a/src/initctl/initctl.c b/src/initctl/initctl.c
index 7484200065..0882570a66 100644
--- a/src/initctl/initctl.c
+++ b/src/initctl/initctl.c
@@ -311,7 +311,7 @@ static int process_event(Server *s, struct epoll_event *ev) {
}
static int run(int argc, char *argv[]) {
- _cleanup_(server_done) Server server = { .epoll_fd = -1 };
+ _cleanup_(server_done) Server server = { .epoll_fd = -EBADF };
_unused_ _cleanup_(notify_on_cleanup) const char *notify_stop = NULL;
int r, n;
diff --git a/src/journal/fuzz-journald-stream.c b/src/journal/fuzz-journald-stream.c
index cece8c440e..ed52f950d2 100644
--- a/src/journal/fuzz-journald-stream.c
+++ b/src/journal/fuzz-journald-stream.c
@@ -9,7 +9,7 @@
#include "fuzz-journald.h"
#include "journald-stream.h"
-static int stream_fds[2] = { -EBADF, -EBADF };
+static int stream_fds[2] = PIPE_EBADF;
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
Server s;
diff --git a/src/libsystemd-network/arp-util.c b/src/libsystemd-network/arp-util.c
index eec794a653..ad61614f12 100644
--- a/src/libsystemd-network/arp-util.c
+++ b/src/libsystemd-network/arp-util.c
@@ -73,7 +73,7 @@ int arp_network_bind_raw_socket(int ifindex, const struct in_addr *a, const stru
.ll.sll_halen = ETH_ALEN,
.ll.sll_addr = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff },
};
- _cleanup_close_ int s = -1;
+ _cleanup_close_ int s = -EBADF;
int r;
assert(ifindex > 0);
diff --git a/src/libsystemd-network/dhcp-network.c b/src/libsystemd-network/dhcp-network.c
index 0ee977a8c8..4e4b1ccb75 100644
--- a/src/libsystemd-network/dhcp-network.c
+++ b/src/libsystemd-network/dhcp-network.c
@@ -98,7 +98,7 @@ static int _bind_raw_socket(
.len = ELEMENTSOF(filter),
.filter = filter
};
- _cleanup_close_ int s = -1;
+ _cleanup_close_ int s = -EBADF;
int r;
s = socket(AF_PACKET, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0);
@@ -178,7 +178,7 @@ int dhcp_network_bind_udp_socket(int ifindex, be32_t address, uint16_t port, int
.in.sin_port = htobe16(port),
.in.sin_addr.s_addr = address,
};
- _cleanup_close_ int s = -1;
+ _cleanup_close_ int s = -EBADF;
int r;
s = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0);
diff --git a/src/libsystemd-network/dhcp6-network.c b/src/libsystemd-network/dhcp6-network.c
index eedd92d3c2..a3e4e19e8e 100644
--- a/src/libsystemd-network/dhcp6-network.c
+++ b/src/libsystemd-network/dhcp6-network.c
@@ -23,7 +23,7 @@ int dhcp6_network_bind_udp_socket(int ifindex, struct in6_addr *local_address) {
.in6.sin6_port = htobe16(DHCP6_PORT_CLIENT),
.in6.sin6_scope_id = ifindex,
};
- _cleanup_close_ int s = -1;
+ _cleanup_close_ int s = -EBADF;
int r;
assert(ifindex > 0);
diff --git a/src/libsystemd-network/fuzz-dhcp6-client.c b/src/libsystemd-network/fuzz-dhcp6-client.c
index 7da285e54e..356a9f48fd 100644
--- a/src/libsystemd-network/fuzz-dhcp6-client.c
+++ b/src/libsystemd-network/fuzz-dhcp6-client.c
@@ -10,7 +10,7 @@
#include "fd-util.h"
#include "fuzz.h"
-static int test_dhcp_fd[2] = { -EBADF, -EBADF };
+static int test_dhcp_fd[2] = PIPE_EBADF;
int dhcp6_network_send_udp_socket(int s, struct in6_addr *server_address, const void *packet, size_t len) {
return len;
diff --git a/src/libsystemd-network/fuzz-lldp-rx.c b/src/libsystemd-network/fuzz-lldp-rx.c
index 00a98bbeb0..2d8e201854 100644
--- a/src/libsystemd-network/fuzz-lldp-rx.c
+++ b/src/libsystemd-network/fuzz-lldp-rx.c
@@ -10,7 +10,7 @@
#include "fuzz.h"
#include "lldp-network.h"
-static int test_fd[2] = { -EBADF, -EBADF };
+static int test_fd[2] = PIPE_EBADF;
int lldp_network_bind_raw_socket(int ifindex) {
if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0, test_fd) < 0)
diff --git a/src/libsystemd-network/fuzz-ndisc-rs.c b/src/libsystemd-network/fuzz-ndisc-rs.c
index b794e2ad42..7a5c45a2f9 100644
--- a/src/libsystemd-network/fuzz-ndisc-rs.c
+++ b/src/libsystemd-network/fuzz-ndisc-rs.c
@@ -4,14 +4,16 @@
#include <netinet/icmp6.h>
#include <unistd.h>
+#include "sd-ndisc.h"
+
#include "alloc-util.h"
-#include "icmp6-util.h"
+#include "fd-util.h"
#include "fuzz.h"
-#include "sd-ndisc.h"
-#include "socket-util.h"
+#include "icmp6-util.h"
#include "ndisc-internal.h"
+#include "socket-util.h"
-static int test_fd[2] = { -EBADF, -EBADF };
+static int test_fd[2] = PIPE_EBADF;
int icmp6_bind_router_solicitation(int index) {
assert_se(socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0, test_fd) >= 0);
diff --git a/src/libsystemd-network/icmp6-util.c b/src/libsystemd-network/icmp6-util.c
index b669531487..00a59291a1 100644
--- a/src/libsystemd-network/icmp6-util.c
+++ b/src/libsystemd-network/icmp6-util.c
@@ -31,7 +31,7 @@
static int icmp6_bind_router_message(const struct icmp6_filter *filter,
const struct ipv6_mreq *mreq) {
int ifindex = mreq->ipv6mr_interface;
- _cleanup_close_ int s = -1;
+ _cleanup_close_ int s = -EBADF;
int r;
assert(filter);
diff --git a/src/libsystemd-network/test-dhcp6-client.c b/src/libsystemd-network/test-dhcp6-client.c
index 7344099e77..3e1c52a306 100644
--- a/src/libsystemd-network/test-dhcp6-client.c
+++ b/src/libsystemd-network/test-dhcp6-client.c
@@ -73,7 +73,7 @@ static const uint8_t server_id[] = { SERVER_ID_BYTES };
static const struct ether_addr mac = {
.ether_addr_octet = { 'A', 'B', 'C', '1', '2', '3' },
};
-static int test_fd[2] = { -EBADF, -EBADF };
+static int test_fd[2] = PIPE_EBADF;
static int test_ifindex = 42;
static unsigned test_client_sent_message_count = 0;
static sd_dhcp6_client *client_ref = NULL;
diff --git a/src/libsystemd-network/test-lldp-rx.c b/src/libsystemd-network/test-lldp-rx.c
index 7ec1ab1ee9..387e1e2203 100644
--- a/src/libsystemd-network/test-lldp-rx.c
+++ b/src/libsystemd-network/test-lldp-rx.c
@@ -20,7 +20,7 @@
#define TEST_LLDP_TYPE_SYSTEM_NAME "systemd-lldp"
#define TEST_LLDP_TYPE_SYSTEM_DESC "systemd-lldp-desc"
-static int test_fd[2] = { -EBADF, -EBADF };
+static int test_fd[2] = PIPE_EBADF;
static int lldp_rx_handler_calls;
int lldp_network_bind_raw_socket(int ifindex) {
diff --git a/src/libsystemd/sd-bus/bus-container.c b/src/libsystemd/sd-bus/bus-container.c
index 4a1d4d2ef8..eddd634d8a 100644
--- a/src/libsystemd/sd-bus/bus-container.c
+++ b/src/libsystemd/sd-bus/bus-container.c
@@ -12,7 +12,7 @@
#include "string-util.h"
int bus_container_connect_socket(sd_bus *b) {
- _cleanup_close_pair_ int pair[2] = { -EBADF, -EBADF };
+ _cleanup_close_pair_ int pair[2] = PIPE_EBADF;
_cleanup_close_ int pidnsfd = -EBADF, mntnsfd = -EBADF, usernsfd = -EBADF, rootfd = -EBADF;
int r, error_buf = 0;
pid_t child;
diff --git a/src/libsystemd/sd-bus/test-bus-benchmark.c b/src/libsystemd/sd-bus/test-bus-benchmark.c
index a402a70223..1eb6edd329 100644
--- a/src/libsystemd/sd-bus/test-bus-benchmark.c
+++ b/src/libsystemd/sd-bus/test-bus-benchmark.c
@@ -211,9 +211,9 @@ int main(int argc, char *argv[]) {
MODE_CHART,
} mode = MODE_BISECT;
Type type = TYPE_LEGACY;
- int i, pair[2] = { -EBADF, -EBADF };
+ int i, pair[2] = PIPE_EBADF;
_cleanup_free_ char *address = NULL, *server_name = NULL;
- _cleanup_close_ int bus_ref = -1;
+ _cleanup_close_ int bus_ref = -EBADF;
const char *unique;
cpu_set_t cpuset;
size_t result;
diff --git a/src/libsystemd/sd-bus/test-bus-chat.c b/src/libsystemd/sd-bus/test-bus-chat.c
index 382761171c..8e66919b46 100644
--- a/src/libsystemd/sd-bus/test-bus-chat.c
+++ b/src/libsystemd/sd-bus/test-bus-chat.c
@@ -260,7 +260,7 @@ static void* client1(void *p) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
const char *hello;
int r;
- _cleanup_close_pair_ int pp[2] = { -EBADF, -EBADF };
+ _cleanup_close_pair_ int pp[2] = PIPE_EBADF;
char x;
r = sd_bus_open_user(&bus);
diff --git a/src/libsystemd/sd-daemon/sd-daemon.c b/src/libsystemd/sd-daemon/sd-daemon.c
index 46125fedf1..6da351dd9b 100644
--- a/src/libsystemd/sd-daemon/sd-daemon.c
+++ b/src/libsystemd/sd-daemon/sd-daemon.c
@@ -549,7 +549,7 @@ finish:
}
_public_ int sd_notify_barrier(int unset_environment, uint64_t timeout) {
- _cleanup_close_pair_ int pipe_fd[2] = { -EBADF, -EBADF };
+ _cleanup_close_pair_ int pipe_fd[2] = PIPE_EBADF;
int r;
if (pipe2(pipe_fd, O_CLOEXEC) < 0)
diff --git a/src/libsystemd/sd-device/device-monitor.c b/src/libsystemd/sd-device/device-monitor.c
index 5c8e043fc6..049b3aa97f 100644
--- a/src/libsystemd/sd-device/device-monitor.c
+++ b/src/libsystemd/sd-device/device-monitor.c
@@ -130,7 +130,7 @@ int device_monitor_get_fd(sd_device_monitor *m) {
int device_monitor_new_full(sd_device_monitor **ret, MonitorNetlinkGroup group, int fd) {
_cleanup_(sd_device_monitor_unrefp) sd_device_monitor *m = NULL;
- _cleanup_close_ int sock = -1;
+ _cleanup_close_ int sock = -EBADF;
int r;
assert(group >= 0 && group < _MONITOR_NETLINK_GROUP_MAX);
@@ -184,7 +184,7 @@ int device_monitor_new_full(sd_device_monitor **ret, MonitorNetlinkGroup group,
}
if (DEBUG_LOGGING) {
- _cleanup_close_ int netns = -1;
+ _cleanup_close_ int netns = -EBADF;
/* So here's the thing: only AF_NETLINK sockets from the main network namespace will get
* hardware events. Let's check if ours is from there, and if not generate a debug message,
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
index b9df1c86c3..ce1104b073 100644
--- a/src/libsystemd/sd-event/sd-event.c
+++ b/src/libsystemd/sd-event/sd-event.c
@@ -2072,7 +2072,7 @@ static int event_add_inotify_fd_internal(
sd_event_inotify_handler_t callback,
void *userdata) {
- _cleanup_close_ int donated_fd = donate ? fd : -1;
+ _cleanup_close_ int donated_fd = donate ? fd : -EBADF;
_cleanup_(source_freep) sd_event_source *s = NULL;
struct inotify_data *inotify_data = NULL;
struct inode_data *inode_data = NULL;
diff --git a/src/libsystemd/sd-event/test-event.c b/src/libsystemd/sd-event/test-event.c
index 7cc4cc9e28..591eab8896 100644
--- a/src/libsystemd/sd-event/test-event.c
+++ b/src/libsystemd/sd-event/test-event.c
@@ -198,8 +198,8 @@ static void test_basic_one(bool with_pidfd) {
sd_event *e = NULL;
sd_event_source *w = NULL, *x = NULL, *y = NULL, *z = NULL, *q = NULL, *t = NULL;
static const char ch = 'x';
- int a[2] = { -EBADF, -EBADF }, b[2] = { -EBADF, -EBADF },
- d[2] = { -EBADF, -EBADF }, k[2] = { -EBADF, -EBADF };
+ int a[2] = PIPE_EBADF, b[2] = PIPE_EBADF,
+ d[2] = PIPE_EBADF, k[2] = PIPE_EBADF;
uint64_t event_now;
int64_t priority;
@@ -628,7 +628,7 @@ static int ratelimit_expired(sd_event_source *s, void *userdata) {
}
TEST(ratelimit) {
- _cleanup_close_pair_ int p[2] = {-1, -1};
+ _cleanup_close_pair_ int p[2] = PIPE_EBADF;
_cleanup_(sd_event_unrefp) sd_event *e = NULL;
_cleanup_(sd_event_source_unrefp) sd_event_source *s = NULL;
uint64_t interval;
diff --git a/src/libsystemd/sd-login/test-login.c b/src/libsystemd/sd-login/test-login.c
index 2b2d1c4b64..96a8c567fc 100644
--- a/src/libsystemd/sd-login/test-login.c
+++ b/src/libsystemd/sd-login/test-login.c
@@ -37,7 +37,7 @@ static const char *e(int r) {
}
TEST(login) {
- _cleanup_close_pair_ int pair[2] = { -EBADF, -EBADF };
+ _cleanup_close_pair_ int pair[2] = PIPE_EBADF;
_cleanup_free_ char *pp = NULL, *qq = NULL,
*display_session = NULL, *cgroup = NULL,
*display = NULL, *remote_user = NULL, *remote_host = NULL,
diff --git a/src/machine/image-dbus.c b/src/machine/image-dbus.c
index f8c09a8b7c..bf65eecfdd 100644
--- a/src/machine/image-dbus.c
+++ b/src/machine/image-dbus.c
@@ -31,7 +31,7 @@ int bus_image_method_remove(
void *userdata,
sd_bus_error *error) {
- _cleanup_close_pair_ int errno_pipe_fd[2] = { -EBADF, -EBADF };
+ _cleanup_close_pair_ int errno_pipe_fd[2] = PIPE_EBADF;
Image *image = ASSERT_PTR(userdata);
Manager *m = image->userdata;
pid_t child;
@@ -145,7 +145,7 @@ int bus_image_method_clone(
void *userdata,
sd_bus_error *error) {
- _cleanup_close_pair_ int errno_pipe_fd[2] = { -EBADF, -EBADF };
+ _cleanup_close_pair_ int errno_pipe_fd[2] = PIPE_EBADF;
Image *image = ASSERT_PTR(userdata);
Manager *m = ASSERT_PTR(image->userdata);
const char *new_name;
diff --git a/src/machine/machine-dbus.c b/src/machine/machine-dbus.c
index 1867893004..7a45811614 100644
--- a/src/machine/machine-dbus.c
+++ b/src/machine/machine-dbus.c
@@ -223,7 +223,7 @@ int bus_machine_method_get_addresses(sd_bus_message *message, void *userdata, sd
}
case MACHINE_CONTAINER: {
- _cleanup_close_pair_ int pair[2] = { -EBADF, -EBADF };
+ _cleanup_close_pair_ int pair[2] = PIPE_EBADF;
_cleanup_free_ char *us = NULL, *them = NULL;
_cleanup_close_ int netns_fd = -EBADF;
const char *p;
@@ -371,7 +371,7 @@ int bus_machine_method_get_os_release(sd_bus_message *message, void *userdata, s
case MACHINE_CONTAINER: {
_cleanup_close_ int mntns_fd = -EBADF, root_fd = -EBADF, pidns_fd = -EBADF;
- _cleanup_close_pair_ int pair[2] = { -EBADF, -EBADF };
+ _cleanup_close_pair_ int pair[2] = PIPE_EBADF;
_cleanup_fclose_ FILE *f = NULL;
pid_t child;
@@ -436,7 +436,7 @@ int bus_machine_method_get_os_release(sd_bus_message *message, void *userdata, s
int bus_machine_method_open_pty(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_free_ char *pty_name = NULL;
- _cleanup_close_ int master = -1;
+ _cleanup_close_ int master = -EBADF;
Machine *m = ASSERT_PTR(userdata);
int r;
@@ -525,7 +525,7 @@ int bus_machine_method_open_login(sd_bus_message *message, void *userdata, sd_bu
_cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL;
_cleanup_free_ char *pty_name = NULL;
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *allocated_bus = NULL;
- _cleanup_close_ int master = -1;
+ _cleanup_close_ int master = -EBADF;
sd_bus *container_bus = NULL;
Machine *m = ASSERT_PTR(userdata);
const char *p, *getty;
@@ -588,7 +588,7 @@ int bus_machine_method_open_shell(sd_bus_message *message, void *userdata, sd_bu
_cleanup_free_ char *pty_name = NULL;
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *allocated_bus = NULL;
sd_bus *container_bus = NULL;
- _cleanup_close_ int master = -1, slave = -1;
+ _cleanup_close_ int master = -EBADF, slave = -EBADF;
_cleanup_strv_free_ char **env = NULL, **args_wire = NULL, **args = NULL;
Machine *m = ASSERT_PTR(userdata);
const char *p, *unit, *user, *path, *description, *utmp_id;
@@ -888,7 +888,7 @@ int bus_machine_method_bind_mount(sd_bus_message *message, void *userdata, sd_bu
int bus_machine_method_copy(sd_bus_message *message, void *userdata, sd_bus_error *error) {
_cleanup_free_ char *host_basename = NULL, *container_basename = NULL;
const char *src, *dest, *host_path, *container_path;
- _cleanup_close_pair_ int errno_pipe_fd[2] = { -EBADF, -EBADF };
+ _cleanup_close_pair_ int errno_pipe_fd[2] = PIPE_EBADF;
CopyFlags copy_flags = COPY_REFLINK|COPY_MERGE|COPY_HARDLINKS;
_cleanup_close_ int hostfd = -EBADF;
Machine *m = ASSERT_PTR(userdata);
@@ -1085,7 +1085,7 @@ int bus_machine_method_open_root_directory(sd_bus_message *message, void *userda
case MACHINE_CONTAINER: {
_cleanup_close_ int mntns_fd = -EBADF, root_fd = -EBADF;
- _cleanup_close_pair_ int pair[2] = { -EBADF, -EBADF };
+ _cleanup_close_pair_ int pair[2] = PIPE_EBADF;
pid_t child;
r = namespace_open(m->leader, NULL, &mntns_fd, NULL, NULL, &root_fd);
diff --git a/src/machine/machined-dbus.c b/src/machine/machined-dbus.c
index ed28627826..0c157a981a 100644
--- a/src/machine/machined-dbus.c
+++ b/src/machine/machined-dbus.c
@@ -683,7 +683,7 @@ static int method_clean_pool(sd_bus_message *message, void *userdata, sd_bus_err
REMOVE_HIDDEN,
} mode;
- _cleanup_close_pair_ int errno_pipe_fd[2] = { -EBADF, -EBADF };
+ _cleanup_close_pair_ int errno_pipe_fd[2] = PIPE_EBADF;
_cleanup_close_ int result_fd = -EBADF;
Manager *m = userdata;
Operation *operation;
diff --git a/src/nspawn/nspawn-setuid.c b/src/nspawn/nspawn-setuid.c
index a91ab9f25e..e396d66441 100644
--- a/src/nspawn/nspawn-setuid.c
+++ b/src/nspawn/nspawn-setuid.c
@@ -39,7 +39,7 @@ static int spawn_getent(const char *database, const char *key, pid_t *rpid) {
pipe_fds[0] = safe_close(pipe_fds[0]);
- if (rearrange_stdio(-1, TAKE_FD(pipe_fds[1]), -1) < 0)
+ if (rearrange_stdio(-EBADF, TAKE_FD(pipe_fds[1]), -EBADF) < 0)
_exit(EXIT_FAILURE);
(void) close_all_fds(NULL, 0);
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index de3e95145b..067efbe3f0 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -2376,7 +2376,7 @@ static int setup_pts(const char *dest) {
}
static int setup_stdio_as_dev_console(void) {
- _cleanup_close_ int terminal = -1;
+ _cleanup_close_ int terminal = -EBADF;
int r;
/* We open the TTY in O_NOCTTY mode, so that we do not become controller yet. We'll do that later
@@ -3348,7 +3348,7 @@ static int inner_child(
}
if (arg_console_mode != CONSOLE_PIPE) {
- _cleanup_close_ int master = -1;
+ _cleanup_close_ int master = -EBADF;
_cleanup_free_ char *console = NULL;
/* Allocate a pty and make it available as /dev/console. */
@@ -4742,12 +4742,12 @@ static int run_container(
};
_cleanup_(release_lock_file) LockFile uid_shift_lock = LOCK_FILE_INIT;
- _cleanup_close_ int etc_passwd_lock = -1;
+ _cleanup_close_ int etc_passwd_lock = -EBADF;
_cleanup_close_pair_ int
- fd_inner_socket_pair[2] = { -EBADF, -EBADF },
- fd_outer_socket_pair[2] = { -EBADF, -EBADF };
+ fd_inner_socket_pair[2] = PIPE_EBADF,
+ fd_outer_socket_pair[2] = PIPE_EBADF;
- _cleanup_close_ int notify_socket = -1, mntns_fd = -EBADF, fd_kmsg_fifo = -EBADF;
+ _cleanup_close_ int notify_socket = -EBADF, mntns_fd = -EBADF, fd_kmsg_fifo = -EBADF;
_cleanup_(barrier_destroy) Barrier barrier = BARRIER_NULL;
_cleanup_(sd_event_source_unrefp) sd_event_source *notify_event_source = NULL;
_cleanup_(sd_event_unrefp) sd_event *event = NULL;
@@ -5413,7 +5413,7 @@ static int cant_be_in_netns(void) {
static int run(int argc, char *argv[]) {
bool secondary = false, remove_directory = false, remove_image = false,
veth_created = false, remove_tmprootdir = false;
- _cleanup_close_ int master = -1;
+ _cleanup_close_ int master = -EBADF;
_cleanup_fdset_free_ FDSet *fds = NULL;
int r, n_fd_passed, ret = EXIT_SUCCESS;
char veth_name[IFNAMSIZ] = "";
diff --git a/src/portable/portable.c b/src/portable/portable.c
index 28d9ccd302..7be1afbcc4 100644
--- a/src/portable/portable.c
+++ b/src/portable/portable.c
@@ -355,7 +355,7 @@ static int portable_extract_by_path(
else {
_cleanup_(dissected_image_unrefp) DissectedImage *m = NULL;
_cleanup_(rmdir_and_freep) char *tmpdir = NULL;
- _cleanup_(close_pairp) int seq[2] = { -EBADF, -EBADF };
+ _cleanup_(close_pairp) int seq[2] = PIPE_EBADF;
_cleanup_(sigkill_waitp) pid_t child = 0;
/* We now have a loopback block device, let's fork off a child in its own mount namespace, mount it
diff --git a/src/portable/portabled-image-bus.c b/src/portable/portabled-image-bus.c
index f0eb71b710..07d10b05bf 100644
--- a/src/portable/portabled-image-bus.c
+++ b/src/portable/portabled-image-bus.c
@@ -486,7 +486,7 @@ int bus_image_common_remove(
Image *image,
sd_bus_error *error) {
- _cleanup_close_pair_ int errno_pipe_fd[2] = { -EBADF, -EBADF };
+ _cleanup_close_pair_ int errno_pipe_fd[2] = PIPE_EBADF;
_cleanup_(sigkill_waitp) pid_t child = 0;
PortableState state;
int r;
diff --git a/src/resolve/resolved-llmnr.c b/src/resolve/resolved-llmnr.c
index 897674ba51..4ab455eb2f 100644
--- a/src/resolve/resolved-llmnr.c
+++ b/src/resolve/resolved-llmnr.c
@@ -141,7 +141,7 @@ int manager_llmnr_ipv4_udp_fd(Manager *m) {
.in.sin_family = AF_INET,
.in.sin_port = htobe16(LLMNR_PORT),
};
- _cleanup_close_ int s = -1;
+ _cleanup_close_ int s = -EBADF;
int r;
assert(m);
@@ -211,7 +211,7 @@ int manager_llmnr_ipv6_udp_fd(Manager *m) {
.in6.sin6_family = AF_INET6,
.in6.sin6_port = htobe16(LLMNR_PORT),
};
- _cleanup_close_ int s = -1;
+ _cleanup_close_ int s = -EBADF;
int r;
assert(m);
@@ -344,7 +344,7 @@ int manager_llmnr_ipv4_tcp_fd(Manager *m) {
.in.sin_family = AF_INET,
.in.sin_port = htobe16(LLMNR_PORT),
};
- _cleanup_close_ int s = -1;
+ _cleanup_close_ int s = -EBADF;
int r;
assert(m);
@@ -410,7 +410,7 @@ int manager_llmnr_ipv6_tcp_fd(Manager *m) {
.in6.sin6_family = AF_INET6,
.in6.sin6_port = htobe16(LLMNR_PORT),
};
- _cleanup_close_ int s = -1;
+ _cleanup_close_ int s = -EBADF;
int r;
assert(m);
diff --git a/src/resolve/resolved-mdns.c b/src/resolve/resolved-mdns.c
index 8d51017b5d..cf6c22df3b 100644
--- a/src/resolve/resolved-mdns.c
+++ b/src/resolve/resolved-mdns.c
@@ -466,7 +466,7 @@ int manager_mdns_ipv4_fd(Manager *m) {
.in.sin_family = AF_INET,
.in.sin_port = htobe16(MDNS_PORT),
};
- _cleanup_close_ int s = -1;
+ _cleanup_close_ int s = -EBADF;
int r;
assert(m);
@@ -541,7 +541,7 @@ int manager_mdns_ipv6_fd(Manager *m) {
.in6.sin6_family = AF_INET6,
.in6.sin6_port = htobe16(MDNS_PORT),
};
- _cleanup_close_ int s = -1;
+ _cleanup_close_ int s = -EBADF;
int r;
assert(m);
diff --git a/src/rfkill/rfkill.c b/src/rfkill/rfkill.c
index 773b25d816..9631513628 100644
--- a/src/rfkill/rfkill.c
+++ b/src/rfkill/rfkill.c
@@ -267,7 +267,7 @@ static void context_save_and_clear(Context *c) {
}
static int run(int argc, char *argv[]) {
- _cleanup_(context_save_and_clear) Context c = { .rfkill_fd = -1 };
+ _cleanup_(context_save_and_clear) Context c = { .rfkill_fd = -EBADF };
bool ready = false;
int r, n;
diff --git a/src/run/run.c b/src/run/run.c
index 5f7d651b90..471d15924a 100644
--- a/src/run/run.c
+++ b/src/run/run.c
@@ -1107,7 +1107,7 @@ static int start_transient_service(
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(bus_wait_for_jobs_freep) BusWaitForJobs *w = NULL;
_cleanup_free_ char *service = NULL, *pty_path = NULL;
- _cleanup_close_ int master = -1;
+ _cleanup_close_ int master = -EBADF;
int r;
assert(bus);
diff --git a/src/shared/copy.c b/src/shared/copy.c
index e103aa0f7f..4eb4f9f765 100644
--- a/src/shared/copy.c
+++ b/src/shared/copy.c
@@ -526,7 +526,7 @@ static int hardlink_context_setup(
const char *to,
CopyFlags copy_flags) {
- _cleanup_close_ int dt_copy = -1;
+ _cleanup_close_ int dt_copy = -EBADF;
int r;
assert(c);
diff --git a/src/shared/data-fd-util.c b/src/shared/data-fd-util.c
index 0a4ef3fffc..895d8e8b33 100644
--- a/src/shared/data-fd-util.c
+++ b/src/shared/data-fd-util.c
@@ -26,7 +26,7 @@
#define DATA_FD_TMP_LIMIT (1024U*1024U)
int acquire_data_fd(const void *data, size_t size, unsigned flags) {
- _cleanup_close_pair_ int pipefds[2] = { -EBADF, -EBADF };
+ _cleanup_close_pair_ int pipefds[2] = PIPE_EBADF;
char pattern[] = "/dev/shm/data-fd-XXXXXX";
_cleanup_close_ int fd = -EBADF;
int isz = 0, r;
@@ -218,7 +218,7 @@ int copy_data_fd(int fd) {
/* Hmm, pity, this didn't fit. Let's fall back to /tmp then, see below */
} else {
- _cleanup_(close_pairp) int pipefds[2] = { -EBADF, -EBADF };
+ _cleanup_(close_pairp) int pipefds[2] = PIPE_EBADF;
int isz;
/* If memfds aren't available, use a pipe. Set O_NONBLOCK so that we will get EAGAIN rather
diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c
index e2905b646d..4351f185cd 100644
--- a/src/shared/dissect-image.c
+++ b/src/shared/dissect-image.c
@@ -2696,7 +2696,7 @@ int dissected_image_acquire_metadata(DissectedImage *m, DissectImageFlags extra_
};
_cleanup_strv_free_ char **machine_info = NULL, **os_release = NULL, **initrd_release = NULL, **extension_release = NULL;
- _cleanup_close_pair_ int error_pipe[2] = { -EBADF, -EBADF };
+ _cleanup_close_pair_ int error_pipe[2] = PIPE_EBADF;
_cleanup_(rmdir_and_freep) char *t = NULL;
_cleanup_(sigkill_waitp) pid_t child = 0;
sd_id128_t machine_id = SD_ID128_NULL;
diff --git a/src/shared/elf-util.c b/src/shared/elf-util.c
index bbe59f7af6..8da16f528f 100644
--- a/src/shared/elf-util.c
+++ b/src/shared/elf-util.c
@@ -744,9 +744,9 @@ static int parse_elf(int fd, const char *executable, char **ret, JsonVariant **r
}
int parse_elf_object(int fd, const char *executable, bool fork_disable_dump, char **ret, JsonVariant **ret_package_metadata) {
- _cleanup_close_pair_ int error_pipe[2] = { -EBADF, -EBADF },
- return_pipe[2] = { -EBADF, -EBADF },
- json_pipe[2] = { -EBADF, -EBADF };
+ _cleanup_close_pair_ int error_pipe[2] = PIPE_EBADF,
+ return_pipe[2] = PIPE_EBADF,
+ json_pipe[2] = PIPE_EBADF;
_cleanup_(json_variant_unrefp) JsonVariant *package_metadata = NULL;
_cleanup_free_ char *buf = NULL;
int r;
diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c
index 1be22a62c6..5c9dd61898 100644
--- a/src/shared/logs-show.c
+++ b/src/shared/logs-show.c
@@ -1624,7 +1624,7 @@ int add_matches_for_user_unit(sd_journal *j, const char *unit, uid_t uid) {
}
static int get_boot_id_for_machine(const char *machine, sd_id128_t *boot_id) {
- _cleanup_close_pair_ int pair[2] = { -EBADF, -EBADF };
+ _cleanup_close_pair_ int pair[2] = PIPE_EBADF;
_cleanup_close_ int pidnsfd = -EBADF, mntnsfd = -EBADF, rootfd = -EBADF;
char buf[SD_ID128_UUID_STRING_MAX];
pid_t pid, child;
diff --git a/src/shared/loop-util.c b/src/shared/loop-util.c
index eb1a5bb59f..3224286186 100644
--- a/src/shared/loop-util.c
+++ b/src/shared/loop-util.c
@@ -683,7 +683,7 @@ int loop_device_make_by_path_memory(
}
static LoopDevice* loop_device_free(LoopDevice *d) {
- _cleanup_close_ int control = -1;
+ _cleanup_close_ int control = -EBADF;
int r;
if (!d)
diff --git a/src/shared/mount-util.c b/src/shared/mount-util.c
index 80cf87526e..603eb7b780 100644
--- a/src/shared/mount-util.c
+++ b/src/shared/mount-util.c
@@ -806,7 +806,7 @@ static int mount_in_namespace(
const MountOptions *options,
bool is_image) {
- _cleanup_close_pair_ int errno_pipe_fd[2] = { -EBADF, -EBADF };
+ _cleanup_close_pair_ int errno_pipe_fd[2] = PIPE_EBADF;
_cleanup_close_ int mntns_fd = -EBADF, root_fd = -EBADF, pidns_fd = -EBADF, chased_src_fd = -EBADF;
char mount_slave[] = "/tmp/propagate.XXXXXX", *mount_tmp, *mount_outside, *p;
bool mount_slave_created = false, mount_slave_mounted = false,
diff --git a/src/shared/pager.c b/src/shared/pager.c
index 831cc1dce0..6ed35a3ca9 100644
--- a/src/shared/pager.c
+++ b/src/shared/pager.c
@@ -83,7 +83,7 @@ static int no_quit_on_interrupt(int exe_name_fd, const char *less_opts) {
}
void pager_open(PagerFlags flags) {
- _cleanup_close_pair_ int fd[2] = { -EBADF, -EBADF }, exe_name_pipe[2] = { -EBADF, -EBADF };
+ _cleanup_close_pair_ int fd[2] = PIPE_EBADF, exe_name_pipe[2] = PIPE_EBADF;
_cleanup_strv_free_ char **pager_args = NULL;
_cleanup_free_ char *l = NULL;
const char *pager, *less_opts;
diff --git a/src/socket-proxy/socket-proxyd.c b/src/socket-proxy/socket-proxyd.c
index d73bdbdc1e..821049e667 100644
--- a/src/socket-proxy/socket-proxyd.c
+++ b/src/socket-proxy/socket-proxyd.c
@@ -487,8 +487,8 @@ static int add_connection_socket(Context *context, int fd) {
.context = context,
.server_fd = fd,
.client_fd = -EBADF,
- .server_to_client_buffer = { -EBADF, -EBADF },
- .client_to_server_buffer = { -EBADF, -EBADF },
+ .server_to_client_buffer = PIPE_EBADF,
+ .client_to_server_buffer = PIPE_EBADF,
};
r = set_ensure_put(&context->connections, NULL, c);
diff --git a/src/sysupdate/sysupdate-resource.c b/src/sysupdate/sysupdate-resource.c
index 759c81a4f0..04d425299d 100644
--- a/src/sysupdate/sysupdate-resource.c
+++ b/src/sysupdate/sysupdate-resource.c
@@ -242,7 +242,7 @@ static int download_manifest(
size_t *ret_size) {
_cleanup_free_ char *buffer = NULL, *suffixed_url = NULL;
- _cleanup_(close_pairp) int pfd[2] = { -EBADF, -EBADF };
+ _cleanup_(close_pairp) int pfd[2] = PIPE_EBADF;
_cleanup_fclose_ FILE *manifest = NULL;
size_t size = 0;
pid_t pid;
@@ -282,7 +282,7 @@ static int download_manifest(
pfd[0] = safe_close(pfd[0]);
- r = rearrange_stdio(-1, pfd[1], STDERR_FILENO);
+ r = rearrange_stdio(-EBADF, pfd[1], STDERR_FILENO);
if (r < 0) {
log_error_errno(r, "Failed to rearrange stdin/stdout: %m");
_exit(EXIT_FAILURE);
diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c
index b68a7d6d5a..6e197b964d 100644
--- a/src/sysusers/sysusers.c
+++ b/src/sysusers/sysusers.c
@@ -251,7 +251,7 @@ static int load_group_database(void) {
static int make_backup(const char *target, const char *x) {
_cleanup_(unlink_and_freep) char *dst_tmp = NULL;
_cleanup_fclose_ FILE *dst = NULL;
- _cleanup_close_ int src = -1;
+ _cleanup_close_ int src = -EBADF;
const char *backup;
struct stat st;
int r;
@@ -2093,7 +2093,7 @@ static int run(int argc, char *argv[]) {
_cleanup_(loop_device_unrefp) LoopDevice *loop_device = NULL;
_cleanup_(umount_and_rmdir_and_freep) char *unlink_dir = NULL;
#endif
- _cleanup_close_ int lock = -1;
+ _cleanup_close_ int lock = -EBADF;
Item *i;
int r;
diff --git a/src/test/test-compress.c b/src/test/test-compress.c
index 339482a438..f5ec47cb3c 100644
--- a/src/test/test-compress.c
+++ b/src/test/test-compress.c
@@ -170,7 +170,7 @@ _unused_ static void test_compress_stream(int flag,
decompress_stream_t decompress,
const char *srcfile) {
- _cleanup_close_ int src = -1, dst = -1, dst2 = -1;
+ _cleanup_close_ int src = -EBADF, dst = -EBADF, dst2 = -EBADF;
_cleanup_(unlink_tempfilep) char
pattern[] = "/tmp/systemd-test.compressed.XXXXXX",
pattern2[] = "/tmp/systemd-test.compressed.XXXXXX";
diff --git a/src/test/test-copy.c b/src/test/test-copy.c
index 2568b9b384..5a4af174fe 100644
--- a/src/test/test-copy.c
+++ b/src/test/test-copy.c
@@ -78,7 +78,7 @@ TEST(copy_tree_replace_file) {
TEST(copy_tree_replace_dirs) {
_cleanup_(rm_rf_physical_and_freep) char *srcp = NULL, *dstp = NULL;
- _cleanup_close_ int src = -1, dst = -1;
+ _cleanup_close_ int src = -EBADF, dst = -EBADF;
/* Create the random source/destination directories */
assert_se((src = mkdtemp_open(NULL, 0, &srcp)) >= 0);
@@ -257,7 +257,7 @@ TEST(copy_tree) {
}
TEST(copy_bytes) {
- _cleanup_close_pair_ int pipefd[2] = {-1, -1};
+ _cleanup_close_pair_ int pipefd[2] = PIPE_EBADF;
_cleanup_close_ int infd = -EBADF;
int r, r2;
char buf[1024], buf2[1024];
diff --git a/src/test/test-data-fd-util.c b/src/test/test-data-fd-util.c
index d69648842e..c0febec208 100644
--- a/src/test/test-data-fd-util.c
+++ b/src/test/test-data-fd-util.c
@@ -81,7 +81,7 @@ static void assert_equal_fd(int fd1, int fd2) {
TEST(copy_data_fd) {
_cleanup_close_ int fd1 = -EBADF, fd2 = -EBADF;
- _cleanup_(close_pairp) int sfd[2] = { -EBADF, -EBADF };
+ _cleanup_(close_pairp) int sfd[2] = PIPE_EBADF;
_cleanup_(sigkill_waitp) pid_t pid = -1;
int r;
diff --git a/src/test/test-execute.c b/src/test/test-execute.c
index 51c3e755e0..7fe78207e0 100644
--- a/src/test/test-execute.c
+++ b/src/test/test-execute.c
@@ -559,7 +559,7 @@ static int find_libraries(const char *exec, char ***ret) {
_cleanup_(sd_event_source_unrefp) sd_event_source *sigchld_source = NULL;
_cleanup_(sd_event_source_unrefp) sd_event_source *stdout_source = NULL;
_cleanup_(sd_event_source_unrefp) sd_event_source *stderr_source = NULL;
- _cleanup_close_pair_ int outpipe[2] = {-1, -1}, errpipe[2] = {-1, -1};
+ _cleanup_close_pair_ int outpipe[2] = PIPE_EBADF, errpipe[2] = PIPE_EBADF;
_cleanup_strv_free_ char **libraries = NULL;
_cleanup_free_ char *result = NULL;
pid_t pid;
@@ -576,7 +576,7 @@ static int find_libraries(const char *exec, char ***ret) {
r = safe_fork("(spawn-ldd)", FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_LOG, &pid);
assert_se(r >= 0);
if (r == 0) {
- if (rearrange_stdio(-1, TAKE_FD(outpipe[1]), TAKE_FD(errpipe[1])) < 0)
+ if (rearrange_stdio(-EBADF, TAKE_FD(outpipe[1]), TAKE_FD(errpipe[1])) < 0)
_exit(EXIT_FAILURE);
(void) close_all_fds(NULL, 0);
diff --git a/src/test/test-fd-util.c b/src/test/test-fd-util.c
index f08d0f0dd4..1ca9ef8bbd 100644
--- a/src/test/test-fd-util.c
+++ b/src/test/test-fd-util.c
@@ -133,7 +133,7 @@ TEST(rearrange_stdio) {
safe_close(STDERR_FILENO); /* Let's close an fd < 2, to make it more interesting */
- assert_se(rearrange_stdio(-1, -1, -1) >= 0);
+ assert_se(rearrange_stdio(-EBADF, -EBADF, -EBADF) >= 0);
assert_se(fd_get_path(STDIN_FILENO, &path) >= 0);
assert_se(path_equal(path, "/dev/null"));
@@ -170,7 +170,7 @@ TEST(rearrange_stdio) {
assert_se(read(0, buffer, sizeof(buffer)) == 6);
assert_se(memcmp(buffer, "foobar", 6) == 0);
- assert_se(rearrange_stdio(-1, 1, 2) >= 0);
+ assert_se(rearrange_stdio(-EBADF, 1, 2) >= 0);
assert_se(write(1, "a", 1) < 0 && errno == ENOSPC);
assert_se(write(2, "y", 1) == 1);
assert_se(read(3, buffer, sizeof(buffer)) == 1);
@@ -532,7 +532,7 @@ TEST(fd_reopen_condition) {
TEST(take_fd) {
_cleanup_close_ int fd1 = -EBADF, fd2 = -EBADF;
- int array[2] = { -EBADF, -EBADF }, i = 0;
+ int array[2] = PIPE_EBADF, i = 0;
assert_se(fd1 == -EBADF);
assert_se(fd2 == -EBADF);
diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c
index 2009c0f972..9d9c719875 100644
--- a/src/test/test-fileio.c
+++ b/src/test/test-fileio.c
@@ -877,7 +877,7 @@ TEST(read_nul_string) {
TEST(read_full_file_socket) {
_cleanup_(rm_rf_physical_and_freep) char *z = NULL;
- _cleanup_close_ int listener = -1;
+ _cleanup_close_ int listener = -EBADF;
_cleanup_free_ char *data = NULL, *clientname = NULL;
union sockaddr_union sa;
const char *j, *jj;
diff --git a/src/test/test-namespace.c b/src/test/test-namespace.c
index be09f71e75..72155127c1 100644
--- a/src/test/test-namespace.c
+++ b/src/test/test-namespace.c
@@ -83,7 +83,7 @@ TEST(tmpdir) {
}
static void test_shareable_ns(unsigned long nsflag) {
- _cleanup_close_pair_ int s[2] = { -EBADF, -EBADF };
+ _cleanup_close_pair_ int s[2] = PIPE_EBADF;
pid_t pid1, pid2, pid3;
int r, n = 0;
siginfo_t si;
diff --git a/src/test/test-terminal-util.c b/src/test/test-terminal-util.c
index 8d0e452038..8d5b24e502 100644
--- a/src/test/test-terminal-util.c
+++ b/src/test/test-terminal-util.c
@@ -66,7 +66,7 @@ TEST(read_one_char) {
TEST(getttyname_malloc) {
_cleanup_free_ char *ttyname = NULL;
- _cleanup_close_ int master = -1;
+ _cleanup_close_ int master = -EBADF;
assert_se((master = posix_openpt(O_RDWR|O_NOCTTY)) >= 0);
assert_se(getttyname_malloc(master, &ttyname) >= 0);
diff --git a/src/test/test-varlink.c b/src/test/test-varlink.c
index 5811259183..e961887fec 100644
--- a/src/test/test-varlink.c
+++ b/src/test/test-varlink.c
@@ -191,7 +191,7 @@ int main(int argc, char *argv[]) {
_cleanup_(rm_rf_physical_and_freep) char *tmpdir = NULL;
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
_cleanup_(sd_event_unrefp) sd_event *e = NULL;
- _cleanup_(close_pairp) int block_fds[2] = { -EBADF, -EBADF };
+ _cleanup_(close_pairp) int block_fds[2] = PIPE_EBADF;
pthread_t t;
const char *sp;
diff --git a/src/timesync/timesyncd-manager.c b/src/timesync/timesyncd-manager.c
index f70873ff6e..b26de6ecd6 100644
--- a/src/timesync/timesyncd-manager.c
+++ b/src/timesync/timesyncd-manager.c
@@ -1113,7 +1113,7 @@ int manager_new(Manager **ret) {
.connection_retry_usec = DEFAULT_CONNECTION_RETRY_USEC,
- .server_socket = -1,
+ .server_socket = -EBADF,
.ratelimit = (const RateLimit) {
RATELIMIT_INTERVAL_USEC,
diff --git a/src/tty-ask-password-agent/tty-ask-password-agent.c b/src/tty-ask-password-agent/tty-ask-password-agent.c
index 9166e1f9ec..46d2307ad3 100644
--- a/src/tty-ask-password-agent/tty-ask-password-agent.c
+++ b/src/tty-ask-password-agent/tty-ask-password-agent.c
@@ -338,7 +338,7 @@ static int process_and_watch_password_files(bool watch) {
};
_unused_ _cleanup_close_ int tty_block_fd = -EBADF;
- _cleanup_close_ int notify = -1, signal_fd = -EBADF;
+ _cleanup_close_ int notify = -EBADF, signal_fd = -EBADF;
struct pollfd pollfd[_FD_MAX];
sigset_t mask;
int r;
diff --git a/src/udev/udev-ctrl.c b/src/udev/udev-ctrl.c
index 625c4faad8..24180f9418 100644
--- a/src/udev/udev-ctrl.c
+++ b/src/udev/udev-ctrl.c
@@ -46,7 +46,7 @@ struct UdevCtrl {
};
int udev_ctrl_new_from_fd(UdevCtrl **ret, int fd) {
- _cleanup_close_ int sock = -1;
+ _cleanup_close_ int sock = -EBADF;
UdevCtrl *uctrl;
assert(ret);
@@ -64,7 +64,7 @@ int udev_ctrl_new_from_fd(UdevCtrl **ret, int fd) {
*uctrl = (UdevCtrl) {
.n_ref = 1,
.sock = fd >= 0 ? fd : TAKE_FD(sock),
- .sock_connect = -1,
+ .sock_connect = -EBADF,
.bound = fd >= 0,
};
@@ -217,7 +217,7 @@ static int udev_ctrl_connection_event_handler(sd_event_source *s, int fd, uint32
static int udev_ctrl_event_handler(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
UdevCtrl *uctrl = ASSERT_PTR(userdata);
- _cleanup_close_ int sock = -1;
+ _cleanup_close_ int sock = -EBADF;
struct ucred ucred;
int r;
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
index 63be5275e4..7a59e7c759 100644
--- a/src/udev/udev-event.c
+++ b/src/udev/udev-event.c
@@ -763,7 +763,7 @@ int udev_event_spawn(
size_t ressize,
bool *ret_truncated) {
- _cleanup_close_pair_ int outpipe[2] = {-1, -1}, errpipe[2] = {-1, -1};
+ _cleanup_close_pair_ int outpipe[2] = PIPE_EBADF, errpipe[2] = PIPE_EBADF;
_cleanup_strv_free_ char **argv = NULL;
char **envp = NULL;
Spawn spawn;
@@ -815,7 +815,7 @@ int udev_event_spawn(
return log_device_error_errno(event->dev, r,
"Failed to fork() to execute command '%s': %m", cmd);
if (r == 0) {
- if (rearrange_stdio(-1, TAKE_FD(outpipe[WRITE_END]), TAKE_FD(errpipe[WRITE_END])) < 0)
+ if (rearrange_stdio(-EBADF, TAKE_FD(outpipe[WRITE_END]), TAKE_FD(errpipe[WRITE_END])) < 0)
_exit(EXIT_FAILURE);
(void) close_all_fds(NULL, 0);
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 4942c852a0..28b76bfbab 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -1848,7 +1848,7 @@ static int manager_new(Manager **ret, int fd_ctrl, int fd_uevent) {
*manager = (Manager) {
.inotify_fd = -EBADF,
- .worker_watch = { -EBADF, -EBADF },
+ .worker_watch = PIPE_EBADF,
.cgroup = TAKE_PTR(cgroup),
};