]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Fix building with gcc 8.2.1 and -Wall -Wextra -pedantic -Werror
authorIlya Leoshkevich <iii@linux.ibm.com>
Tue, 26 Mar 2019 09:52:02 +0000 (10:52 +0100)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Wed, 27 Mar 2019 12:01:02 +0000 (13:01 +0100)
* ptrdiff_t check always failed because of unused parameter
* sizeof(void *) check always failed because of double semicolon
* Sign issue in nice_match assignment
* dist parameter of set_bytes may be unused
* Parameters of main may be unused in test/example.c
* snprintf requires a _POSIX_C_SOURCE #define in test/minigzip.c,
  because a _POSIX_SOURCE #define is present

configure
match_p.h
memcopy.h
test/example.c
test/minigzip.c

index 91ae5be558e491f48dc86a3a779babe3a0e76653..6b35df7d46dc8f85fd28093a1fc02474604e7127 100755 (executable)
--- a/configure
+++ b/configure
@@ -718,7 +718,7 @@ echo >> configure.log
 echo -n "Checking for ptrdiff_t... " | tee -a configure.log
 cat > $test.c <<EOF
 #include <stddef.h>
-int fun(ptrdiff_t *a) { return 0; }
+int fun(ptrdiff_t *a) { (void)a; return 0; }
 EOF
 if try $CC -c $CFLAGS $test.c; then
   echo "Yes." | tee -a configure.log
@@ -730,7 +730,7 @@ else
     echo -n "Checking for sizeof(void *)... " | tee -a configure.log
     cat > $test.c <<EOF
 #include <stdint.h>
-#define COMPILE_TIME_ASSERT(pred) struct s { int x: (pred) ? 1 : -1; };
+#define COMPILE_TIME_ASSERT(pred) struct s { int x: (pred) ? 1 : -1; }
 COMPILE_TIME_ASSERT(sizeof(int32_t) == sizeof(void *));
 EOF
     if try $CC -c $CFLAGS $test.c; then
@@ -740,7 +740,7 @@ EOF
     else
         cat > $test.c <<EOF
 #include <stdint.h>
-#define COMPILE_TIME_ASSERT(pred) struct s { int x: (pred) ? 1 : -1; };
+#define COMPILE_TIME_ASSERT(pred) struct s { int x: (pred) ? 1 : -1; }
 COMPILE_TIME_ASSERT(sizeof(int64_t) == sizeof(void *));
 EOF
         if try $CC -c $CFLAGS $test.c; then
index d381eebfd1989cabfd78f78e087d05bd5ba83357..b956d8d52004283374dc97443daf904fd82d77ad 100644 (file)
--- a/match_p.h
+++ b/match_p.h
@@ -75,7 +75,7 @@ static inline unsigned longest_match(deflate_state *const s, IPos cur_match) {
      * Do not looks for matches beyond the end of the input. This is
      * necessary to make deflate deterministic
      */
-    nice_match = (unsigned int)s->nice_match > s->lookahead ? s->lookahead : s->nice_match;
+    nice_match = (unsigned int)s->nice_match > s->lookahead ? s->lookahead : (unsigned int)s->nice_match;
 
     /*
      * Stop when cur_match becomes <= limit. To simplify the code,
index 9ce391106d3f25bdbd3bc72c470fcaa1c0b60150..301aa5f732c321a2b199a7ffd576ad6b3d45c220 100644 (file)
--- a/memcopy.h
+++ b/memcopy.h
@@ -401,6 +401,7 @@ static inline unsigned char *set_bytes(unsigned char *out, unsigned char *from,
     Assert(len < 8, "set_bytes should be called with less than 8 bytes");
 
  #ifndef UNALIGNED_OK
+    (void)dist;
     while (len--) {
         *out++ = *from++;
     }
index 7567fc5d2ff7de1bd70192cf2229efd1528504c8..13a828b72b884702d1cfdf9efd6f36471e505575 100644 (file)
@@ -538,6 +538,9 @@ int main(int argc, char *argv[])
 #ifdef WITH_GZFILEOP
     test_gzio((argc > 1 ? argv[1] : TESTFILE),
               uncompr, uncomprLen);
+#else
+    (void)argc;
+    (void)argv;
 #endif
 
     test_deflate(compr, comprLen);
index 3f21b1abeceadb75df2f09d616c33efe815f7850..e8ae9ef88f596fd44c7d238f73585fd6ea2f4f89 100644 (file)
@@ -15,6 +15,7 @@
 /* @(#) $Id$ */
 
 #define _POSIX_SOURCE 1  /* This file needs POSIX for fdopen(). */
+#define _POSIX_C_SOURCE 200112  /* For snprintf(). */
 
 #include "zbuild.h"
 #ifdef ZLIB_COMPAT