From fb8dd62f77d88808bbe342b72eca41e6ac0ec7e0 Mon Sep 17 00:00:00 2001 From: Mark Adler Date: Tue, 10 Feb 2026 18:24:49 -0800 Subject: Clean up the use of switch cases. --- gzread.c | 4 ++++ infback.c | 2 +- inflate.c | 2 +- inftrees.c | 10 ++++------ 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/gzread.c b/gzread.c index b198a44c..bbabf522 100644 --- a/gzread.c +++ b/gzread.c @@ -267,6 +267,10 @@ local int gz_fetch(gz_statep state) { strm->next_out = state->out; if (gz_decomp(state) == -1) return -1; + break; + default: + gz_error(state, Z_STREAM_ERROR, "state corrupt"); + return -1; } } while (state->x.have == 0 && (!state->eof || strm->avail_in)); return 0; diff --git a/infback.c b/infback.c index 518bf3e7..8cb7654c 100644 --- a/infback.c +++ b/infback.c @@ -252,7 +252,7 @@ int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc, state->last ? " (last)" : "")); state->mode = TABLE; break; - case 3: + default: strm->msg = (z_const char *)"invalid block type"; state->mode = BAD; } diff --git a/inflate.c b/inflate.c index f55949e8..6baa4dfe 100644 --- a/inflate.c +++ b/inflate.c @@ -738,7 +738,7 @@ int ZEXPORT inflate(z_streamp strm, int flush) { state->last ? " (last)" : "")); state->mode = TABLE; break; - case 3: + default: strm->msg = (z_const char *)"invalid block type"; state->mode = BAD; } diff --git a/inftrees.c b/inftrees.c index 6b6f8dc4..2a468717 100644 --- a/inftrees.c +++ b/inftrees.c @@ -57,9 +57,9 @@ int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, unsigned mask; /* mask for low root bits */ code here; /* table entry for duplication */ code FAR *next; /* next available space in table */ - const unsigned short FAR *base; /* base value table to use */ - const unsigned short FAR *extra; /* extra bits table to use */ - unsigned match; /* use base and extra for symbol >= match */ + const unsigned short FAR *base = NULL; /* base value table to use */ + const unsigned short FAR *extra = NULL; /* extra bits table to use */ + unsigned match = 0; /* use base and extra for symbol >= match */ unsigned short count[MAXBITS+1]; /* number of codes of each length */ unsigned short offs[MAXBITS+1]; /* offsets in table for each length */ static const unsigned short lbase[31] = { /* Length codes 257..285 base */ @@ -185,7 +185,6 @@ int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, /* set up for code type */ switch (type) { case CODES: - base = extra = work; /* dummy value--not used */ match = 20; break; case LENS: @@ -193,10 +192,9 @@ int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, extra = lext; match = 257; break; - default: /* DISTS */ + case DISTS: base = dbase; extra = dext; - match = 0; } /* initialize state for loop */ -- cgit v1.2.3-55-g6feb