mirror of
https://github.com/systemd/systemd.git
synced 2024-11-26 19:53:45 +08:00
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; | ~~~~~~~~~~^~~ ```
This commit is contained in:
parent
b4bc798f87
commit
6604fb0207
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user