From 6604fb0207ee10e8dc05d67f6fe45de0b193b5c4 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Fri, 16 Apr 2021 10:08:36 +0900 Subject: [PATCH] fileio: use take_fdopen_unlocked() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes maybe-uninitialized warning: ``` ../src/basic/fileio.c: In function ‘chase_symlinks_and_fopen_unlocked’: ../src/basic/fileio.c:1026:19: warning: ‘f’ may be used uninitialized in this function [-Wmaybe-uninitialized] 1026 | *ret_file = f; | ~~~~~~~~~~^~~ ``` --- src/basic/fileio.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/basic/fileio.c b/src/basic/fileio.c index adfde64cbc8..414fd15d567 100644 --- a/src/basic/fileio.c +++ b/src/basic/fileio.c @@ -57,7 +57,7 @@ int fdopen_unlocked(int fd, const char *options, FILE **ret) { } int take_fdopen_unlocked(int *fd, const char *options, FILE **ret) { - int r; + int r; assert(fd); @@ -1004,7 +1004,6 @@ int chase_symlinks_and_fopen_unlocked( _cleanup_close_ int fd = -1; _cleanup_free_ char *final_path = NULL; int mode_flags, r; - FILE *f; assert(path); assert(open_flags); @@ -1018,12 +1017,10 @@ int chase_symlinks_and_fopen_unlocked( if (fd < 0) return fd; - r = fdopen_unlocked(fd, open_flags, &f); + r = take_fdopen_unlocked(&fd, open_flags, ret_file); if (r < 0) return r; - TAKE_FD(fd); - *ret_file = f; if (ret_path) *ret_path = TAKE_PTR(final_path); return 0;