]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: initialize fds with -EBADF
authorDavid Tardon <dtardon@redhat.com>
Thu, 23 Feb 2023 08:48:54 +0000 (09:48 +0100)
committerDavid Tardon <dtardon@redhat.com>
Thu, 23 Feb 2023 08:48:54 +0000 (09:48 +0100)
src/basic/chase-symlinks.c
src/boot/bootctl-status.c
src/libsystemd/sd-event/sd-event.c
src/shared/loop-util.c
src/test/test-mempress.c

index 3a4fdcd1e0247b4e53b359b2b9a7a2cab2ebacf6..7cbe0b45ae02e3bff0f41fba631297e8f463c7a9 100644 (file)
@@ -705,7 +705,7 @@ int chase_symlinks_and_unlink(
                 char **ret_path) {
 
         _cleanup_free_ char *p = NULL, *rp = NULL, *dir = NULL, *fname = NULL;
-        _cleanup_close_ int fd = -1;
+        _cleanup_close_ int fd = -EBADF;
         int r;
 
         assert(path);
index 8586e64480bf10f6881681c0534ec28cf0b543dd..1b17712a90d6f1ccb9c1237870c89ed65158cfb7 100644 (file)
@@ -718,7 +718,7 @@ static int cleanup_orphaned_files(
 
         _cleanup_(hashmap_free_free_keyp) Hashmap *known_files = NULL;
         _cleanup_free_ char *full = NULL, *p = NULL;
-        _cleanup_close_ int dir_fd = -1;
+        _cleanup_close_ int dir_fd = -EBADF;
         int r = -1;
 
         assert(config);
index 46292da2a1f3e5c7ecd7b83fcb0a015494eb33d0..73b5267ae8179f0594302bc352c99ae73ad02f36 100644 (file)
@@ -1915,7 +1915,7 @@ _public_ int sd_event_add_memory_pressure(
 
         _cleanup_free_ char *w = NULL;
         _cleanup_(source_freep) sd_event_source *s = NULL;
-        _cleanup_close_ int path_fd = -1, fd = -1;
+        _cleanup_close_ int path_fd = -EBADF, fd = -EBADF;
         _cleanup_free_ void *write_buffer = NULL;
         const char *watch, *watch_fallback = NULL, *env;
         size_t write_buffer_size = 0;
index 049ec21ab9465d2955e8fefee275e4dcbcb4d09d..6e187efe94b65f5e89d75ce7b71d85586a1e0db2 100644 (file)
@@ -504,7 +504,7 @@ static int loop_device_make_internal(
                          * the underlying block device. */
                         r = blockdev_get_sector_size(fd, &sector_size);
                 else {
-                        _cleanup_close_ int non_direct_io_fd = -1;
+                        _cleanup_close_ int non_direct_io_fd = -EBADF;
                         int probe_fd;
 
                         assert(S_ISREG(st.st_mode));
index 3371965ac3358981af1057bdc0f821ae1f52dc3b..510c7327156428b7024673e0ef3a0ca28cabe7cc 100644 (file)
@@ -28,7 +28,7 @@ struct fake_pressure_context {
 
 static void *fake_pressure_thread(void *p) {
         _cleanup_free_ struct fake_pressure_context *c = ASSERT_PTR(p);
-        _cleanup_close_ int cfd = -1;
+        _cleanup_close_ int cfd = -EBADF;
 
         usleep(150);
 
@@ -68,7 +68,7 @@ TEST(fake_pressure) {
         _cleanup_(sd_event_unrefp) sd_event *e = NULL;
         _cleanup_free_ char *j = NULL, *k = NULL;
         _cleanup_(rm_rf_physical_and_freep) char *tmp = NULL;
-        _cleanup_close_ int fifo_fd = -1, socket_fd = -1;
+        _cleanup_close_ int fifo_fd = -EBADF, socket_fd = -EBADF;
         union sockaddr_union sa;
         pthread_t th;
         int value = 7;