Merge pull request #26563 from dtardon/fd-init

Initialize fds with -EBADF + drop one unneeded initialization
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2023-02-23 11:43:09 +01:00
committed by GitHub
5 changed files with 7 additions and 7 deletions
+1 -1
View 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);
+2 -2
View File
@@ -718,8 +718,8 @@ 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;
int r = -1;
_cleanup_close_ int dir_fd = -EBADF;
int r;
assert(config);
assert(root);
+1 -1
View 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;
+1 -1
View 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));
+2 -2
View 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;