From: Yu Watanabe Date: Fri, 16 Apr 2021 01:08:36 +0000 (+0900) Subject: fileio: use take_fdopen_unlocked() X-Git-Tag: v249-rc1~398 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6604fb0207ee10e8dc05d67f6fe45de0b193b5c4;p=thirdparty%2Fsystemd.git fileio: use take_fdopen_unlocked() 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; | ~~~~~~~~~~^~~ ``` --- 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;