Subject: | Compilation warnings with gcc-7.* |
Hello Paul,
Every year it seems that compilers get pickier about the C-source code originating or bundled with the Perl 5 distribution. This year is no different. As more gcc users upgrade to version 7 -- now, mostly gcc-7.2 -- Perl's 'make' has to deal with newly added warnings. See, e.g., http://perl5.test-smoke.org/report/58814. Over the past two weeks we've eliminated many of these warnings from the p5p-maintained part of the core distribution. So now our attention turns to the "cpan-upstream" code bundled with the core.
I'm attaching a patch drawn against the version of Compress-Raw-Zlib bundled with Perl 5 blead as of today, Oct 22, 2017. This patch silences the following warning in two source code files:
#####
warning: this statement may fall through [-Wimplicit-fallthrough=]
#####
Note: Although I would like to see this patch applied, I suspect that dealing with https://rt.cpan.org/Ticket/Display.html?id=123245 should probably be higher priority.
Thank you very much for your continued work on this library.
Jim Keenan
Subject: | 0001-Compress-Raw-Zlib-avert-implicit-fallthrough-warning.patch |
From 65ecc37c28121f43a0eedd0aab12146f00ed94d2 Mon Sep 17 00:00:00 2001
From: James E Keenan <jkeenan@cpan.org>
Date: Sun, 22 Oct 2017 18:15:25 -0400
Subject: [PATCH] Compress-Raw-Zlib: avert 'implicit-fallthrough' warnings when
compiling with gcc-7.
---
cpan/Compress-Raw-Zlib/zlib-src/infback.c | 1 +
cpan/Compress-Raw-Zlib/zlib-src/inflate.c | 18 ++++++++++++++++++
2 files changed, 19 insertions(+)
diff --git a/cpan/Compress-Raw-Zlib/zlib-src/infback.c b/cpan/Compress-Raw-Zlib/zlib-src/infback.c
index cff17ee..4890b71 100644
--- a/cpan/Compress-Raw-Zlib/zlib-src/infback.c
+++ b/cpan/Compress-Raw-Zlib/zlib-src/infback.c
@@ -477,6 +477,7 @@ int ZEXPORT inflateBack(
}
Tracev((stderr, "inflate: codes ok\n"));
state->mode = LEN;
+ /* FALLTHROUGH */
case LEN:
/* use inflate_fast() if we have enough input and output */
diff --git a/cpan/Compress-Raw-Zlib/zlib-src/inflate.c b/cpan/Compress-Raw-Zlib/zlib-src/inflate.c
index 6047cd8..a1fb14d 100644
--- a/cpan/Compress-Raw-Zlib/zlib-src/inflate.c
+++ b/cpan/Compress-Raw-Zlib/zlib-src/inflate.c
@@ -718,6 +718,7 @@ int ZEXPORT inflate(
if (state->flags & 0x0200) CRC2(state->check, hold);
INITBITS();
state->mode = EXLEN;
+ /* FALLTHROUGH */
case EXLEN:
if (state->flags & 0x0400) {
NEEDBITS(16);
@@ -730,6 +731,7 @@ int ZEXPORT inflate(
else if (state->head != Z_NULL)
state->head->extra = Z_NULL;
state->mode = EXTRA;
+ /* FALLTHROUGH */
case EXTRA:
if (state->flags & 0x0400) {
copy = state->length;
@@ -752,6 +754,7 @@ int ZEXPORT inflate(
}
state->length = 0;
state->mode = NAME;
+ /* FALLTHROUGH */
case NAME:
if (state->flags & 0x0800) {
if (have == 0) goto inf_leave;
@@ -773,6 +776,7 @@ int ZEXPORT inflate(
state->head->name = Z_NULL;
state->length = 0;
state->mode = COMMENT;
+ /* FALLTHROUGH */
case COMMENT:
if (state->flags & 0x1000) {
if (have == 0) goto inf_leave;
@@ -793,6 +797,7 @@ int ZEXPORT inflate(
else if (state->head != Z_NULL)
state->head->comment = Z_NULL;
state->mode = HCRC;
+ /* FALLTHROUGH */
case HCRC:
if (state->flags & 0x0200) {
NEEDBITS(16);
@@ -816,6 +821,7 @@ int ZEXPORT inflate(
strm->adler = state->check = ZSWAP32(hold);
INITBITS();
state->mode = DICT;
+ /* FALLTHROUGH */
case DICT:
if (state->havedict == 0) {
RESTORE();
@@ -823,8 +829,10 @@ int ZEXPORT inflate(
}
strm->adler = state->check = adler32(0L, Z_NULL, 0);
state->mode = TYPE;
+ /* FALLTHROUGH */
case TYPE:
if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
+ /* FALLTHROUGH */
case TYPEDO:
if (state->last) {
BYTEBITS();
@@ -875,8 +883,10 @@ int ZEXPORT inflate(
INITBITS();
state->mode = COPY_;
if (flush == Z_TREES) goto inf_leave;
+ /* FALLTHROUGH */
case COPY_:
state->mode = COPY;
+ /* FALLTHROUGH */
case COPY:
copy = state->length;
if (copy) {
@@ -1016,8 +1026,10 @@ int ZEXPORT inflate(
Tracev((stderr, "inflate: codes ok\n"));
state->mode = LEN_;
if (flush == Z_TREES) goto inf_leave;
+ /* FALLTHROUGH */
case LEN_:
state->mode = LEN;
+ /* FALLTHROUGH */
case LEN:
if (have >= 6 && left >= 258) {
RESTORE();
@@ -1067,6 +1079,7 @@ int ZEXPORT inflate(
}
state->extra = (unsigned)(here.op) & 15;
state->mode = LENEXT;
+ /* FALLTHROUGH */
case LENEXT:
if (state->extra) {
NEEDBITS(state->extra);
@@ -1077,6 +1090,7 @@ int ZEXPORT inflate(
Tracevv((stderr, "inflate: length %u\n", state->length));
state->was = state->length;
state->mode = DIST;
+ /* FALLTHROUGH */
case DIST:
for (;;) {
here = state->distcode[BITS(state->distbits)];
@@ -1104,6 +1118,7 @@ int ZEXPORT inflate(
state->offset = (unsigned)here.val;
state->extra = (unsigned)(here.op) & 15;
state->mode = DISTEXT;
+ /* FALLTHROUGH */
case DISTEXT:
if (state->extra) {
NEEDBITS(state->extra);
@@ -1120,6 +1135,7 @@ int ZEXPORT inflate(
#endif
Tracevv((stderr, "inflate: distance %u\n", state->offset));
state->mode = MATCH;
+ /* FALLTHROUGH */
case MATCH:
if (left == 0) goto inf_leave;
copy = out - left;
@@ -1195,6 +1211,7 @@ int ZEXPORT inflate(
}
#ifdef GUNZIP
state->mode = LENGTH;
+ /* FALLTHROUGH */
case LENGTH:
if (state->wrap && state->flags) {
NEEDBITS(32);
@@ -1208,6 +1225,7 @@ int ZEXPORT inflate(
}
#endif
state->mode = DONE;
+ /* FALLTHROUGH */
case DONE:
ret = Z_STREAM_END;
goto inf_leave;
--
2.7.4