Merge zlib warning fixes by rurban

https://github.com/madler/zlib/compare/develop...rurban:FALLTHROUGH?d=1.patch
This commit is contained in:
vit9696 2021-10-07 19:10:36 +03:00
parent 2a083d8739
commit 963671a73e
3 changed files with 32 additions and 8 deletions

View File

@ -600,10 +600,11 @@ int ZEXPORT deflateParams(strm, level, strategy)
} }
if (s->level != level) { if (s->level != level) {
if (s->level == 0 && s->matches != 0) { if (s->level == 0 && s->matches != 0) {
if (s->matches == 1) if (s->matches == 1) {
slide_hash(s); slide_hash(s);
else } else {
CLEAR_HASH(s); CLEAR_HASH(s);
}
s->matches = 0; s->matches = 0;
} }
s->level = level; s->level = level;
@ -1120,12 +1121,12 @@ int ZEXPORT deflateCopy (dest, source)
ss = source->state; ss = source->state;
zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream)); zmemcpy((Bytef*)dest, (const Bytef*)source, sizeof(z_stream));
ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state)); ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state));
if (ds == Z_NULL) return Z_MEM_ERROR; if (ds == Z_NULL) return Z_MEM_ERROR;
dest->state = (struct internal_state FAR *) ds; dest->state = (struct internal_state FAR *) ds;
zmemcpy((voidpf)ds, (voidpf)ss, sizeof(deflate_state)); zmemcpy((Bytef*)ds, (const Bytef*)ss, sizeof(deflate_state));
ds->strm = dest; ds->strm = dest;
ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
@ -1141,8 +1142,8 @@ int ZEXPORT deflateCopy (dest, source)
} }
/* following zmemcpy do not work for 16-bit MSDOS */ /* following zmemcpy do not work for 16-bit MSDOS */
zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte)); zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));
zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos)); zmemcpy((Bytef*)ds->prev, (const Bytef*)ss->prev, ds->w_size * sizeof(Pos));
zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos)); zmemcpy((Bytef*)ds->head, (const Bytef*)ss->head, ds->hash_size * sizeof(Pos));
zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size); zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size);
ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);

View File

@ -477,6 +477,7 @@ void FAR *out_desc;
} }
Tracev((stderr, "inflate: codes ok\n")); Tracev((stderr, "inflate: codes ok\n"));
state->mode = LEN; state->mode = LEN;
/* FALLTHROUGH */
case LEN: case LEN:
/* use inflate_fast() if we have enough input and output */ /* use inflate_fast() if we have enough input and output */

View File

@ -722,6 +722,7 @@ int flush;
CRC2(state->check, hold); CRC2(state->check, hold);
INITBITS(); INITBITS();
state->mode = TIME; state->mode = TIME;
/* FALLTHROUGH */
case TIME: case TIME:
NEEDBITS(32); NEEDBITS(32);
if (state->head != Z_NULL) if (state->head != Z_NULL)
@ -730,6 +731,7 @@ int flush;
CRC4(state->check, hold); CRC4(state->check, hold);
INITBITS(); INITBITS();
state->mode = OS; state->mode = OS;
/* FALLTHROUGH */
case OS: case OS:
NEEDBITS(16); NEEDBITS(16);
if (state->head != Z_NULL) { if (state->head != Z_NULL) {
@ -740,6 +742,7 @@ int flush;
CRC2(state->check, hold); CRC2(state->check, hold);
INITBITS(); INITBITS();
state->mode = EXLEN; state->mode = EXLEN;
/* FALLTHROUGH */
case EXLEN: case EXLEN:
if (state->flags & 0x0400) { if (state->flags & 0x0400) {
NEEDBITS(16); NEEDBITS(16);
@ -753,6 +756,7 @@ int flush;
else if (state->head != Z_NULL) else if (state->head != Z_NULL)
state->head->extra = Z_NULL; state->head->extra = Z_NULL;
state->mode = EXTRA; state->mode = EXTRA;
/* FALLTHROUGH */
case EXTRA: case EXTRA:
if (state->flags & 0x0400) { if (state->flags & 0x0400) {
copy = state->length; copy = state->length;
@ -775,6 +779,7 @@ int flush;
} }
state->length = 0; state->length = 0;
state->mode = NAME; state->mode = NAME;
/* FALLTHROUGH */
case NAME: case NAME:
if (state->flags & 0x0800) { if (state->flags & 0x0800) {
if (have == 0) goto inf_leave; if (have == 0) goto inf_leave;
@ -796,6 +801,7 @@ int flush;
state->head->name = Z_NULL; state->head->name = Z_NULL;
state->length = 0; state->length = 0;
state->mode = COMMENT; state->mode = COMMENT;
/* FALLTHROUGH */
case COMMENT: case COMMENT:
if (state->flags & 0x1000) { if (state->flags & 0x1000) {
if (have == 0) goto inf_leave; if (have == 0) goto inf_leave;
@ -816,6 +822,7 @@ int flush;
else if (state->head != Z_NULL) else if (state->head != Z_NULL)
state->head->comment = Z_NULL; state->head->comment = Z_NULL;
state->mode = HCRC; state->mode = HCRC;
/* FALLTHROUGH */
case HCRC: case HCRC:
if (state->flags & 0x0200) { if (state->flags & 0x0200) {
NEEDBITS(16); NEEDBITS(16);
@ -839,6 +846,7 @@ int flush;
strm->adler = state->check = ZSWAP32(hold); strm->adler = state->check = ZSWAP32(hold);
INITBITS(); INITBITS();
state->mode = DICT; state->mode = DICT;
/* FALLTHROUGH */
case DICT: case DICT:
if (state->havedict == 0) { if (state->havedict == 0) {
RESTORE(); RESTORE();
@ -846,8 +854,10 @@ int flush;
} }
strm->adler = state->check = adler32(0L, Z_NULL, 0); strm->adler = state->check = adler32(0L, Z_NULL, 0);
state->mode = TYPE; state->mode = TYPE;
/* FALLTHROUGH */
case TYPE: case TYPE:
if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave; if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
/* FALLTHROUGH */
case TYPEDO: case TYPEDO:
if (state->last) { if (state->last) {
BYTEBITS(); BYTEBITS();
@ -898,8 +908,10 @@ int flush;
INITBITS(); INITBITS();
state->mode = COPY_; state->mode = COPY_;
if (flush == Z_TREES) goto inf_leave; if (flush == Z_TREES) goto inf_leave;
/* FALLTHROUGH */
case COPY_: case COPY_:
state->mode = COPY; state->mode = COPY;
/* FALLTHROUGH */
case COPY: case COPY:
copy = state->length; copy = state->length;
if (copy) { if (copy) {
@ -935,6 +947,7 @@ int flush;
Tracev((stderr, "inflate: table sizes ok\n")); Tracev((stderr, "inflate: table sizes ok\n"));
state->have = 0; state->have = 0;
state->mode = LENLENS; state->mode = LENLENS;
/* FALLTHROUGH */
case LENLENS: case LENLENS:
while (state->have < state->ncode) { while (state->have < state->ncode) {
NEEDBITS(3); NEEDBITS(3);
@ -956,6 +969,7 @@ int flush;
Tracev((stderr, "inflate: code lengths ok\n")); Tracev((stderr, "inflate: code lengths ok\n"));
state->have = 0; state->have = 0;
state->mode = CODELENS; state->mode = CODELENS;
/* FALLTHROUGH */
case CODELENS: case CODELENS:
while (state->have < state->nlen + state->ndist) { while (state->have < state->nlen + state->ndist) {
for (;;) { for (;;) {
@ -1039,8 +1053,10 @@ int flush;
Tracev((stderr, "inflate: codes ok\n")); Tracev((stderr, "inflate: codes ok\n"));
state->mode = LEN_; state->mode = LEN_;
if (flush == Z_TREES) goto inf_leave; if (flush == Z_TREES) goto inf_leave;
/* FALLTHROUGH */
case LEN_: case LEN_:
state->mode = LEN; state->mode = LEN;
/* FALLTHROUGH */
case LEN: case LEN:
if (have >= 6 && left >= 258) { if (have >= 6 && left >= 258) {
RESTORE(); RESTORE();
@ -1090,6 +1106,7 @@ int flush;
} }
state->extra = (unsigned)(here.op) & 15; state->extra = (unsigned)(here.op) & 15;
state->mode = LENEXT; state->mode = LENEXT;
/* FALLTHROUGH */
case LENEXT: case LENEXT:
if (state->extra) { if (state->extra) {
NEEDBITS(state->extra); NEEDBITS(state->extra);
@ -1100,6 +1117,7 @@ int flush;
Tracevv((stderr, "inflate: length %u\n", state->length)); Tracevv((stderr, "inflate: length %u\n", state->length));
state->was = state->length; state->was = state->length;
state->mode = DIST; state->mode = DIST;
/* FALLTHROUGH */
case DIST: case DIST:
for (;;) { for (;;) {
here = state->distcode[BITS(state->distbits)]; here = state->distcode[BITS(state->distbits)];
@ -1127,6 +1145,7 @@ int flush;
state->offset = (unsigned)here.val; state->offset = (unsigned)here.val;
state->extra = (unsigned)(here.op) & 15; state->extra = (unsigned)(here.op) & 15;
state->mode = DISTEXT; state->mode = DISTEXT;
/* FALLTHROUGH */
case DISTEXT: case DISTEXT:
if (state->extra) { if (state->extra) {
NEEDBITS(state->extra); NEEDBITS(state->extra);
@ -1143,6 +1162,7 @@ int flush;
#endif #endif
Tracevv((stderr, "inflate: distance %u\n", state->offset)); Tracevv((stderr, "inflate: distance %u\n", state->offset));
state->mode = MATCH; state->mode = MATCH;
/* FALLTHROUGH */
case MATCH: case MATCH:
if (left == 0) goto inf_leave; if (left == 0) goto inf_leave;
copy = out - left; copy = out - left;
@ -1218,6 +1238,7 @@ int flush;
} }
#ifdef GUNZIP #ifdef GUNZIP
state->mode = LENGTH; state->mode = LENGTH;
/* FALLTHROUGH */
case LENGTH: case LENGTH:
if (state->wrap && state->flags) { if (state->wrap && state->flags) {
NEEDBITS(32); NEEDBITS(32);
@ -1231,6 +1252,7 @@ int flush;
} }
#endif #endif
state->mode = DONE; state->mode = DONE;
/* FALLTHROUGH */
case DONE: case DONE:
ret = Z_STREAM_END; ret = Z_STREAM_END;
goto inf_leave; goto inf_leave;
@ -1487,8 +1509,8 @@ z_streamp source;
} }
/* copy state */ /* copy state */
zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream)); zmemcpy((Bytef*)dest, (const Bytef*)source, sizeof(z_stream));
zmemcpy((voidpf)copy, (voidpf)state, sizeof(struct inflate_state)); zmemcpy((Bytef*)copy, (const Bytef*)state, sizeof(struct inflate_state));
copy->strm = dest; copy->strm = dest;
if (state->lencode >= state->codes && if (state->lencode >= state->codes &&
state->lencode <= state->codes + ENOUGH - 1) { state->lencode <= state->codes + ENOUGH - 1) {