From: Ilya Leoshkevich Date: Tue, 26 Mar 2019 09:52:02 +0000 (+0100) Subject: Fix building with gcc 8.2.1 and -Wall -Wextra -pedantic -Werror X-Git-Tag: 1.9.9-b1~495 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3714bcf395ae1146645f0f2590b914e715569bf3;p=thirdparty%2Fzlib-ng.git Fix building with gcc 8.2.1 and -Wall -Wextra -pedantic -Werror * 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 --- diff --git a/configure b/configure index 91ae5be5..6b35df7d 100755 --- a/configure +++ b/configure @@ -718,7 +718,7 @@ echo >> configure.log echo -n "Checking for ptrdiff_t... " | tee -a configure.log cat > $test.c < -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 < -#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 < -#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 diff --git a/match_p.h b/match_p.h index d381eebf..b956d8d5 100644 --- 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, diff --git a/memcopy.h b/memcopy.h index 9ce39110..301aa5f7 100644 --- 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++; } diff --git a/test/example.c b/test/example.c index 7567fc5d..13a828b7 100644 --- a/test/example.c +++ b/test/example.c @@ -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); diff --git a/test/minigzip.c b/test/minigzip.c index 3f21b1ab..e8ae9ef8 100644 --- a/test/minigzip.c +++ b/test/minigzip.c @@ -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