Commit fb8dd62 for zlib
commit fb8dd62f77d88808bbe342b72eca41e6ac0ec7e0
Author: Mark Adler <git@madler.net>
Date: Tue Feb 10 18:24:49 2026 -0800
Clean up the use of switch cases.
diff --git a/gzread.c b/gzread.c
index b198a44..bbabf52 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 518bf3e..8cb7654 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 f55949e..6baa4df 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 6b6f8dc..2a46871 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 */