basic/tmpfile: avoid maybe-uninitialized warning in mkostemp_safe()

The variable is always initialized, but the compiler might not notice
that. With gcc-9.2.1-1.fc31:

    $ CFLAGS='-Werror=maybe-uninitialized -Og' meson build
    $ ninja -C build
    [...]
    ../src/basic/tmpfile-util.c: In function ‘mkostemp_safe’:
    ../src/basic/tmpfile-util.c:76:12: error: ‘fd’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
       76 |         if (fd < 0)
          |            ^
This commit is contained in:
Thomas Haller 2019-12-15 15:50:43 +01:00 committed by Zbigniew Jędrzejewski-Szmek
parent cb180b09fa
commit e40b4caa1f
1 changed files with 1 additions and 1 deletions

View File

@ -67,7 +67,7 @@ int fopen_temporary(const char *path, FILE **ret_f, char **ret_temp_path) {
/* This is much like mkostemp() but is subject to umask(). */
int mkostemp_safe(char *pattern) {
int fd;
int fd = -1; /* avoid false maybe-uninitialized warning */
assert(pattern);