]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
remove build warning about 'fdopen'
authorSebastian Pop <s.pop@samsung.com>
Fri, 7 Dec 2018 18:39:59 +0000 (12:39 -0600)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Tue, 11 Dec 2018 11:10:39 +0000 (12:10 +0100)
zlib-ng/test/fuzz/minigzip_fuzzer.c:153:31: warning: implicit declaration of function 'fdopen' is invalid in C99 [-Wimplicit-function-declaration]
    gz->file = path == NULL ? fdopen(fd, gz->write ? "wb" : "rb") :
                              ^
zlib-ng/test/fuzz/minigzip_fuzzer.c:153:29: warning: pointer/integer type mismatch in conditional expression ('int' and 'FILE *' (aka 'struct _IO_FILE *'))
      [-Wconditional-type-mismatch]
    gz->file = path == NULL ? fdopen(fd, gz->write ? "wb" : "rb") :
                            ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

test/fuzz/minigzip_fuzzer.c

index 375bab5889673ed8e148208c96587104aa791caf..73d25bb47a4a154120fe5529830aa97321069d0a 100644 (file)
@@ -150,8 +150,15 @@ gzFile gz_open(const char *path, int fd, const char *mode)
         free(gz);
         return NULL;
     }
-    gz->file = path == NULL ? fdopen(fd, gz->write ? "wb" : "rb") :
-                              fopen(path, gz->write ? "wb" : "rb");
+#if _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _POSIX_SOURCE
+    gz->file = path == NULL ? fdopen(fd, gz->write ? "wb" : "rb")
+                            : fopen(path, gz->write ? "wb" : "rb");
+#else
+    /* fdopen is not available in C99. */
+    if (path == NULL)
+      exit(1);
+    gz->file = fopen(path, gz->write ? "wb" : "rb");
+#endif
     if (gz->file == NULL) {
         gz->write ? PREFIX(deflateEnd)(&(gz->strm)) : PREFIX(inflateEnd)(&(gz->strm));
         free(gz);