]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: use -EBADF also in pipe initializers
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 19 Dec 2022 12:20:30 +0000 (13:20 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 19 Dec 2022 14:00:59 +0000 (15:00 +0100)
In some places, initialization is dropped when unnecesary.

42 files changed:
src/basic/terminal-util.c
src/core/automount.c
src/core/dynamic-user.c
src/core/execute.c
src/core/service.c
src/core/socket.c
src/fsck/fsck.c
src/fuzz/fuzz-varlink.c
src/import/import-common.c
src/import/importd.c
src/import/pull-common.c
src/journal/fuzz-journald-stream.c
src/libsystemd-network/fuzz-dhcp6-client.c
src/libsystemd-network/fuzz-lldp-rx.c
src/libsystemd-network/fuzz-ndisc-rs.c
src/libsystemd-network/test-dhcp6-client.c
src/libsystemd-network/test-lldp-rx.c
src/libsystemd/sd-bus/bus-container.c
src/libsystemd/sd-bus/test-bus-benchmark.c
src/libsystemd/sd-bus/test-bus-chat.c
src/libsystemd/sd-daemon/sd-daemon.c
src/libsystemd/sd-event/test-event.c
src/libsystemd/sd-login/test-login.c
src/machine/image-dbus.c
src/machine/machine-dbus.c
src/machine/machined-dbus.c
src/portable/portable.c
src/portable/portabled-image-bus.c
src/shared/data-fd-util.c
src/shared/dissect-image.c
src/shared/elf-util.c
src/shared/logs-show.c
src/shared/mount-util.c
src/shared/pager.c
src/socket-proxy/socket-proxyd.c
src/sysupdate/sysupdate-resource.c
src/test/test-data-fd-util.c
src/test/test-fd-util.c
src/test/test-namespace.c
src/test/test-socket-util.c
src/test/test-varlink.c
src/udev/udevd.c

index da03a884f843a12cc3c2ad8b1bee05a482ed4d48..6afcf066cd10bd50209d8ee488a38eccc667edc3 100644 (file)
@@ -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] = { -1, -1 };
+        _cleanup_close_pair_ int pair[2] = { -EBADF, -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] = { -1, -1 };
+        _cleanup_close_pair_ int pair[2] = { -EBADF, -EBADF };
         pid_t child;
         int r;
 
index d2976d6734e9bb589b75ec3a9cd2b97cb8498318..361034d7f4f20b426704e1d7fb07d5442d997873 100644 (file)
@@ -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);
index e0b371a4c4ec0e53d406277f60cec1d8f24872c3..763f5d4c84616cadb0aa7fc3024aed416442e525 100644 (file)
@@ -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;
 
index 94021f20e81cf101cc36b258d6f492eb813af713..5784c8ce5c22d918bfccfe1f45af1acaa78962c6 100644 (file)
@@ -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);
index 5181826c84cc26a4376b9dcca8ce602031a91827..c967dc989796c4bc68f5b17f693f5cc2e48340d1 100644 (file)
@@ -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);
index e0e91dba53e633989f1c0491d02146716035622a..518f27705395a8fa4794ead29f475b94aa3314f8 100644 (file)
@@ -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;
 
index f5c0732cf5981beb41972cb46efe64e0fb923f01..29265d9220ed09dc398f363f1b3852e2238b7952 100644 (file)
@@ -241,7 +241,7 @@ static int fsck_progress_socket(void) {
 }
 
 static int run(int argc, char *argv[]) {
-        _cleanup_close_pair_ int progress_pipe[2] = { -1, -1 };
+        _cleanup_close_pair_ int progress_pipe[2] = { -EBADF, -EBADF };
         _cleanup_(sd_device_unrefp) sd_device *dev = NULL;
         _cleanup_free_ char *dpath = NULL;
         _cleanup_fclose_ FILE *console = NULL;
index 397c20dca6cd5137f0e8f88949c57eb4d18779cf..c97586be9efe28f5ff8000ba3c5f066cd8c87b0f 100644 (file)
@@ -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] = { -1, -1 }, client_pair[2] = { -1, -1 };
+        _cleanup_close_pair_ int server_pair[2] = { -EBADF, -EBADF }, client_pair[2] = { -EBADF, -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;
index 3c46aedf61896f30d1f11f9913cd3ce3c97da5b2..eb52c6c116c9af345300e844f61387d4e16f9897 100644 (file)
@@ -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] = { -1, -1 };
+        _cleanup_close_pair_ int pipefd[2] = { -EBADF, -EBADF };
         bool use_selinux;
         pid_t pid;
         int r;
@@ -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] = { -1, -1 };
+        _cleanup_close_pair_ int pipefd[2] = { -EBADF, -EBADF };
         bool use_selinux;
         pid_t pid;
         int r;
index b2d176b4e739e94f795d17a1c407fe300e54f92b..b6d90cde103e5699c45dec4db5f8c17ca5044585 100644 (file)
@@ -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] = { -1, -1 };
+        _cleanup_close_pair_ int pipefd[2] = { -EBADF, -EBADF };
         int r;
 
         assert(t);
index 7633d3e74b3c170cf7dbca6244263fd7ad115cc4..1c7194fd6b153d1cdf224936bb3a67b52fffafc5 100644 (file)
@@ -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] = { -1, -1 };
+        _cleanup_close_pair_ int gpg_pipe[2] = { -EBADF, -EBADF };
         char sig_file_path[] = "/tmp/sigXXXXXX", gpg_home[] = "/tmp/gpghomeXXXXXX";
         _cleanup_(sigkill_waitp) pid_t pid = 0;
         bool gpg_home_created = false;
index 67e990ab7cb8b7e793dd110504e40a79dc149d98..cece8c440e88487bde3df9c96420f966610c9bd4 100644 (file)
@@ -9,7 +9,7 @@
 #include "fuzz-journald.h"
 #include "journald-stream.h"
 
-static int stream_fds[2] = { -1, -1 };
+static int stream_fds[2] = { -EBADF, -EBADF };
 
 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
         Server s;
index a1c34365c0301dbcd80e038da770da091b5932ab..7da285e54e37a428e207fb679bf5be1968c99dbf 100644 (file)
@@ -10,7 +10,7 @@
 #include "fd-util.h"
 #include "fuzz.h"
 
-static int test_dhcp_fd[2] = { -1, -1 };
+static int test_dhcp_fd[2] = { -EBADF, -EBADF };
 
 int dhcp6_network_send_udp_socket(int s, struct in6_addr *server_address, const void *packet, size_t len) {
         return len;
index 6419075a4a5bfc1106f7da51cffd588e345d3c4a..00a98bbeb0ec97b85aef356e903f60b790043797 100644 (file)
@@ -10,7 +10,7 @@
 #include "fuzz.h"
 #include "lldp-network.h"
 
-static int test_fd[2] = { -1, -1 };
+static int test_fd[2] = { -EBADF, -EBADF };
 
 int lldp_network_bind_raw_socket(int ifindex) {
         if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0, test_fd) < 0)
index b294611fab6fce583d36e5432a5a2afefe333ed7..b794e2ad423ccd2161b17eb36c704e27478e74c0 100644 (file)
@@ -11,7 +11,7 @@
 #include "socket-util.h"
 #include "ndisc-internal.h"
 
-static int test_fd[2] = { -1, -1 };
+static int test_fd[2] = { -EBADF, -EBADF };
 
 int icmp6_bind_router_solicitation(int index) {
         assert_se(socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0, test_fd) >= 0);
index c3c89514f8daf6a0ba9012b92660ea8f0ee530f5..7344099e77e6045e88347d5deffa07739dcb3237 100644 (file)
@@ -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] = { -1, -1, };
+static int test_fd[2] = { -EBADF, -EBADF };
 static int test_ifindex = 42;
 static unsigned test_client_sent_message_count = 0;
 static sd_dhcp6_client *client_ref = NULL;
index 11049a85b919924b4dbdbe4d70241c4dc1c13c0b..7ec1ab1ee90e519b80220a1d18bb7cd59e1c2a13 100644 (file)
@@ -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] = { -1, -1 };
+static int test_fd[2] = { -EBADF, -EBADF };
 static int lldp_rx_handler_calls;
 
 int lldp_network_bind_raw_socket(int ifindex) {
index 3047dce85810a7d8ed56b52ef23b7b5b1d5fd7d9..4a1d4d2ef82dc33ad4ecbeace35226deb3958021 100644 (file)
@@ -12,7 +12,7 @@
 #include "string-util.h"
 
 int bus_container_connect_socket(sd_bus *b) {
-        _cleanup_close_pair_ int pair[2] = { -1, -1 };
+        _cleanup_close_pair_ int pair[2] = { -EBADF, -EBADF };
         _cleanup_close_ int pidnsfd = -EBADF, mntnsfd = -EBADF, usernsfd = -EBADF, rootfd = -EBADF;
         int r, error_buf = 0;
         pid_t child;
index 7d7dc390dd51442a35f500d92d89191f84feefc8..a402a70223a02d6d8c780b313ab48501cfc65ace 100644 (file)
@@ -211,7 +211,7 @@ int main(int argc, char *argv[]) {
                 MODE_CHART,
         } mode = MODE_BISECT;
         Type type = TYPE_LEGACY;
-        int i, pair[2] = { -1, -1 };
+        int i, pair[2] = { -EBADF, -EBADF };
         _cleanup_free_ char *address = NULL, *server_name = NULL;
         _cleanup_close_ int bus_ref = -1;
         const char *unique;
index 9b5efcce5975e6d5ce6cb17811ce0f269c8e6b6b..382761171c64a4ff5a737e5327b155b49aabd584 100644 (file)
@@ -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] = { -1, -1 };
+        _cleanup_close_pair_ int pp[2] = { -EBADF, -EBADF };
         char x;
 
         r = sd_bus_open_user(&bus);
index 91f96051717c2e8b1d489e3e839fbd395ac98112..46125fedf113671b6d11b9174ab9375ac543be0d 100644 (file)
@@ -549,7 +549,7 @@ finish:
 }
 
 _public_ int sd_notify_barrier(int unset_environment, uint64_t timeout) {
-        _cleanup_close_pair_ int pipe_fd[2] = { -1, -1 };
+        _cleanup_close_pair_ int pipe_fd[2] = { -EBADF, -EBADF };
         int r;
 
         if (pipe2(pipe_fd, O_CLOEXEC) < 0)
index 8d0cb5861bd8127718632c52190c7d62a6d16e0a..7cc4cc9e28382b125c52d8dc41d15a239c708506 100644 (file)
@@ -198,7 +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] = { -1, -1 }, b[2] = { -1, -1}, d[2] = { -1, -1}, k[2] = { -1, -1 };
+        int a[2] = { -EBADF, -EBADF }, b[2] = { -EBADF, -EBADF },
+            d[2] = { -EBADF, -EBADF }, k[2] = { -EBADF, -EBADF };
         uint64_t event_now;
         int64_t priority;
 
index f7cef6e304caf5fe13769c837532bc8ae98d3734..2b2d1c4b64000049972fc4b4873ee4864f548620 100644 (file)
@@ -37,7 +37,7 @@ static const char *e(int r) {
 }
 
 TEST(login) {
-        _cleanup_close_pair_ int pair[2] = { -1, -1 };
+        _cleanup_close_pair_ int pair[2] = { -EBADF, -EBADF };
         _cleanup_free_ char *pp = NULL, *qq = NULL,
                 *display_session = NULL, *cgroup = NULL,
                 *display = NULL, *remote_user = NULL, *remote_host = NULL,
index 698052dd8660f106254daa4d68eb68908145f4cf..f8c09a8b7cf34c0b942bcfdc4da731f33d588f20 100644 (file)
@@ -31,7 +31,7 @@ int bus_image_method_remove(
                 void *userdata,
                 sd_bus_error *error) {
 
-        _cleanup_close_pair_ int errno_pipe_fd[2] = { -1, -1 };
+        _cleanup_close_pair_ int errno_pipe_fd[2] = { -EBADF, -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] = { -1, -1 };
+        _cleanup_close_pair_ int errno_pipe_fd[2] = { -EBADF, -EBADF };
         Image *image = ASSERT_PTR(userdata);
         Manager *m = ASSERT_PTR(image->userdata);
         const char *new_name;
index 26ba5d4292193566647addaa65e4d979a1a06355..1867893004d959b6f6fc4b4ab080536281672198 100644 (file)
@@ -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] = { -1, -1 };
+                _cleanup_close_pair_ int pair[2] = { -EBADF, -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] = { -1, -1 };
+                _cleanup_close_pair_ int pair[2] = { -EBADF, -EBADF };
                 _cleanup_fclose_ FILE *f = NULL;
                 pid_t child;
 
@@ -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] = { -1, -1 };
+        _cleanup_close_pair_ int errno_pipe_fd[2] = { -EBADF, -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] = { -1, -1 };
+                _cleanup_close_pair_ int pair[2] = { -EBADF, -EBADF };
                 pid_t child;
 
                 r = namespace_open(m->leader, NULL, &mntns_fd, NULL, NULL, &root_fd);
index aef3e905426ff514879c7c7c8096c665e1e4e282..ed2862782694ef5c36c97d60e141f677de65b7fe 100644 (file)
@@ -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] = { -1, -1 };
+        _cleanup_close_pair_ int errno_pipe_fd[2] = { -EBADF, -EBADF };
         _cleanup_close_ int result_fd = -EBADF;
         Manager *m = userdata;
         Operation *operation;
index 45dd70b13d7256fe59a3c35bd19457aaf9d900c9..28d9ccd302d6ad49f5b80483dd42412b06533959 100644 (file)
@@ -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] = { -1, -1 };
+                _cleanup_(close_pairp) int seq[2] = { -EBADF, -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
index 704b51d81d86a38954d4ad65235cabdae340909c..f0eb71b7103591f15ca92f58be7dd5bc51062137 100644 (file)
@@ -486,7 +486,7 @@ int bus_image_common_remove(
                 Image *image,
                 sd_bus_error *error) {
 
-        _cleanup_close_pair_ int errno_pipe_fd[2] = { -1, -1 };
+        _cleanup_close_pair_ int errno_pipe_fd[2] = { -EBADF, -EBADF };
         _cleanup_(sigkill_waitp) pid_t child = 0;
         PortableState state;
         int r;
index 15d31ac20ce2488e4cb3e281fe6f5eecaad22f60..0a4ef3fffc21591985783bda0c937c981e3a807e 100644 (file)
@@ -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] = { -1, -1 };
+        _cleanup_close_pair_ int pipefds[2] = { -EBADF, -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] = { -1, -1 };
+                        _cleanup_(close_pairp) int pipefds[2] = { -EBADF, -EBADF };
                         int isz;
 
                         /* If memfds aren't available, use a pipe. Set O_NONBLOCK so that we will get EAGAIN rather
index c9acc2e3063200afae6988e4e41bebf4b9a8b12e..e2905b646dc2ab64b0bece6b4b27a069a9a68b9f 100644 (file)
@@ -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] = { -1, -1 };
+        _cleanup_close_pair_ int error_pipe[2] = { -EBADF, -EBADF };
         _cleanup_(rmdir_and_freep) char *t = NULL;
         _cleanup_(sigkill_waitp) pid_t child = 0;
         sd_id128_t machine_id = SD_ID128_NULL;
index 0c694d79f3a61b54cc17bcbb1466d83a29b431c5..bbe59f7af6b1c436a1f558a0e1ebf1c102a2eb1f 100644 (file)
@@ -744,7 +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] = { -1, -1 }, return_pipe[2] = { -1, -1 }, json_pipe[2] = { -1, -1 };
+        _cleanup_close_pair_ int error_pipe[2] = { -EBADF, -EBADF },
+                                 return_pipe[2] = { -EBADF, -EBADF },
+                                 json_pipe[2] = { -EBADF, -EBADF };
         _cleanup_(json_variant_unrefp) JsonVariant *package_metadata = NULL;
         _cleanup_free_ char *buf = NULL;
         int r;
index 535b61704482370b6117008e0116cc0a78d48e21..1be22a62c6ed1a2069c69d30e5bb72e6545922dd 100644 (file)
@@ -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] = { -1, -1 };
+        _cleanup_close_pair_ int pair[2] = { -EBADF, -EBADF };
         _cleanup_close_ int pidnsfd = -EBADF, mntnsfd = -EBADF, rootfd = -EBADF;
         char buf[SD_ID128_UUID_STRING_MAX];
         pid_t pid, child;
index 6e4fa4a486907b2302663f80bc3a8edb99256ae5..80cf87526ee0a45b5a248d57a85bd65b1806dcec 100644 (file)
@@ -806,7 +806,7 @@ static int mount_in_namespace(
                 const MountOptions *options,
                 bool is_image) {
 
-        _cleanup_close_pair_ int errno_pipe_fd[2] = { -1, -1 };
+        _cleanup_close_pair_ int errno_pipe_fd[2] = { -EBADF, -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,
index 74a6f9fd419cc82049a48b846eea30ef45a39886..831cc1dce04e1e5f05c457f1e45d54a65285ce03 100644 (file)
@@ -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] = { -1, -1 }, exe_name_pipe[2] = { -1, -1 };
+        _cleanup_close_pair_ int fd[2] = { -EBADF, -EBADF }, exe_name_pipe[2] = { -EBADF, -EBADF };
         _cleanup_strv_free_ char **pager_args = NULL;
         _cleanup_free_ char *l = NULL;
         const char *pager, *less_opts;
index c3bb293520a8c36c04211da62b651dbbc671a70b..d73bdbdc1ea6e798a6b4286da4b1149028bd69a3 100644 (file)
@@ -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 = {-1, -1},
-               .client_to_server_buffer = {-1, -1},
+               .server_to_client_buffer = { -EBADF, -EBADF },
+               .client_to_server_buffer = { -EBADF, -EBADF },
         };
 
         r = set_ensure_put(&context->connections, NULL, c);
index 56ce9b31cf50f13ac28298a43c878ecb735219a5..759c81a4f0b8bd9ba33ce9ca636f491dd157e35a 100644 (file)
@@ -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] = { -1, -1 };
+        _cleanup_(close_pairp) int pfd[2] = { -EBADF, -EBADF };
         _cleanup_fclose_ FILE *manifest = NULL;
         size_t size = 0;
         pid_t pid;
index d466ba93150f07b1420899f23ca701dd798aa9c2..d69648842e0889543d981d83a41f8586b74cdb50 100644 (file)
@@ -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] = { -1, -1 };
+        _cleanup_(close_pairp) int sfd[2] = { -EBADF, -EBADF };
         _cleanup_(sigkill_waitp) pid_t pid = -1;
         int r;
 
index b546933ea45a19f8235905beefc1a59dc8986f9c..f08d0f0dd47adf422686aa99902a9a44af078532 100644 (file)
@@ -58,7 +58,7 @@ TEST(close_nointr) {
 }
 
 TEST(same_fd) {
-        _cleanup_close_pair_ int p[2] = { -1, -1 };
+        _cleanup_close_pair_ int p[2];
         _cleanup_close_ int a, b, c;
 
         assert_se(pipe2(p, O_CLOEXEC) >= 0);
index 74f3c9c7c825da3e8feea866f363dc340a520f1f..be09f71e75233f609923c300a113fc3a4bfbb0a3 100644 (file)
@@ -83,7 +83,7 @@ TEST(tmpdir) {
 }
 
 static void test_shareable_ns(unsigned long nsflag) {
-        _cleanup_close_pair_ int s[2] = { -1, -1 };
+        _cleanup_close_pair_ int s[2] = { -EBADF, -EBADF };
         pid_t pid1, pid2, pid3;
         int r, n = 0;
         siginfo_t si;
index 6456316aae641ba0d3681986d5d152e806d1bbf4..dbafe8b058947f58e2cea82df641b518c247e2d6 100644 (file)
@@ -223,7 +223,7 @@ TEST(getpeercred_getpeergroups) {
 
 TEST(passfd_read) {
         static const char file_contents[] = "test contents for passfd";
-        _cleanup_close_pair_ int pair[2] = { -1, -1 };
+        _cleanup_close_pair_ int pair[2];
         int r;
 
         assert_se(socketpair(AF_UNIX, SOCK_DGRAM, 0, pair) >= 0);
@@ -263,7 +263,7 @@ TEST(passfd_read) {
 }
 
 TEST(passfd_contents_read) {
-        _cleanup_close_pair_ int pair[2] = { -1, -1 };
+        _cleanup_close_pair_ int pair[2];
         static const char file_contents[] = "test contents in the file";
         static const char wire_contents[] = "test contents on the wire";
         int r;
@@ -311,7 +311,7 @@ TEST(passfd_contents_read) {
 }
 
 TEST(receive_nopassfd) {
-        _cleanup_close_pair_ int pair[2] = { -1, -1 };
+        _cleanup_close_pair_ int pair[2];
         static const char wire_contents[] = "no fd passed here";
         int r;
 
@@ -348,7 +348,7 @@ TEST(receive_nopassfd) {
 }
 
 TEST(send_nodata_nofd) {
-        _cleanup_close_pair_ int pair[2] = { -1, -1 };
+        _cleanup_close_pair_ int pair[2];
         int r;
 
         assert_se(socketpair(AF_UNIX, SOCK_DGRAM, 0, pair) >= 0);
@@ -381,7 +381,7 @@ TEST(send_nodata_nofd) {
 }
 
 TEST(send_emptydata) {
-        _cleanup_close_pair_ int pair[2] = { -1, -1 };
+        _cleanup_close_pair_ int pair[2];
         int r;
 
         assert_se(socketpair(AF_UNIX, SOCK_DGRAM, 0, pair) >= 0);
index 7515da52ba98bfbc4177a04bba4664043e00b270..58112591831b4a488ea7c1a25784a86e6c69bcc2 100644 (file)
@@ -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] = { -1, -1 };
+        _cleanup_(close_pairp) int block_fds[2] = { -EBADF, -EBADF };
         pthread_t t;
         const char *sp;
 
index 0de5b4ec643f35785ac05c7c409acf36fda67767..4942c852a0b19faf9088f2a20913944c0f0ee3cb 100644 (file)
@@ -1848,7 +1848,7 @@ static int manager_new(Manager **ret, int fd_ctrl, int fd_uevent) {
 
         *manager = (Manager) {
                 .inotify_fd = -EBADF,
-                .worker_watch = { -1, -1 },
+                .worker_watch = { -EBADF, -EBADF },
                 .cgroup = TAKE_PTR(cgroup),
         };