From: David Tardon Date: Thu, 23 Feb 2023 08:48:54 +0000 (+0100) Subject: tree-wide: initialize fds with -EBADF X-Git-Tag: v254-rc1~1177^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=92651a7a2d291ca6bc4d16b1861e494d44870365;p=thirdparty%2Fsystemd.git tree-wide: initialize fds with -EBADF --- diff --git a/src/basic/chase-symlinks.c b/src/basic/chase-symlinks.c index 3a4fdcd1e02..7cbe0b45ae0 100644 --- a/src/basic/chase-symlinks.c +++ b/src/basic/chase-symlinks.c @@ -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); diff --git a/src/boot/bootctl-status.c b/src/boot/bootctl-status.c index 8586e64480b..1b17712a90d 100644 --- a/src/boot/bootctl-status.c +++ b/src/boot/bootctl-status.c @@ -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); diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c index 46292da2a1f..73b5267ae81 100644 --- a/src/libsystemd/sd-event/sd-event.c +++ b/src/libsystemd/sd-event/sd-event.c @@ -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; diff --git a/src/shared/loop-util.c b/src/shared/loop-util.c index 049ec21ab94..6e187efe94b 100644 --- a/src/shared/loop-util.c +++ b/src/shared/loop-util.c @@ -504,7 +504,7 @@ static int loop_device_make_internal( * the underlying block device. */ r = blockdev_get_sector_size(fd, §or_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)); diff --git a/src/test/test-mempress.c b/src/test/test-mempress.c index 3371965ac33..510c7327156 100644 --- a/src/test/test-mempress.c +++ b/src/test/test-mempress.c @@ -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;