2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-09-02 15:25:58 +00:00

Add ZFALLTHROUGH macro to use instead of /* FALLTHROUGH */ comments.

This commit is contained in:
Todd C. Miller
2020-08-01 13:43:27 -06:00
parent 03ad96e445
commit c87a47735d
3 changed files with 26 additions and 19 deletions

View File

@@ -477,7 +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 */ ZFALLTHROUGH;
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

@@ -740,7 +740,7 @@ int flush;
CRC2(state->check, hold); CRC2(state->check, hold);
INITBITS(); INITBITS();
state->mode = EXLEN; state->mode = EXLEN;
/* FALLTHROUGH */ ZFALLTHROUGH;
case EXLEN: case EXLEN:
if (state->flags & 0x0400) { if (state->flags & 0x0400) {
NEEDBITS(16); NEEDBITS(16);
@@ -754,7 +754,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 */ ZFALLTHROUGH;
case EXTRA: case EXTRA:
if (state->flags & 0x0400) { if (state->flags & 0x0400) {
copy = state->length; copy = state->length;
@@ -777,7 +777,7 @@ int flush;
} }
state->length = 0; state->length = 0;
state->mode = NAME; state->mode = NAME;
/* FALLTHROUGH */ ZFALLTHROUGH;
case NAME: case NAME:
if (state->flags & 0x0800) { if (state->flags & 0x0800) {
if (have == 0) goto inf_leave; if (have == 0) goto inf_leave;
@@ -799,7 +799,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 */ ZFALLTHROUGH;
case COMMENT: case COMMENT:
if (state->flags & 0x1000) { if (state->flags & 0x1000) {
if (have == 0) goto inf_leave; if (have == 0) goto inf_leave;
@@ -820,7 +820,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 */ ZFALLTHROUGH;
case HCRC: case HCRC:
if (state->flags & 0x0200) { if (state->flags & 0x0200) {
NEEDBITS(16); NEEDBITS(16);
@@ -844,7 +844,7 @@ int flush;
strm->adler = state->check = ZSWAP32(hold); strm->adler = state->check = ZSWAP32(hold);
INITBITS(); INITBITS();
state->mode = DICT; state->mode = DICT;
/* FALLTHROUGH */ ZFALLTHROUGH;
case DICT: case DICT:
if (state->havedict == 0) { if (state->havedict == 0) {
RESTORE(); RESTORE();
@@ -852,10 +852,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 */ ZFALLTHROUGH;
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 */ ZFALLTHROUGH;
case TYPEDO: case TYPEDO:
if (state->last) { if (state->last) {
BYTEBITS(); BYTEBITS();
@@ -906,10 +906,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 */ ZFALLTHROUGH;
case COPY_: case COPY_:
state->mode = COPY; state->mode = COPY;
/* FALLTHROUGH */ ZFALLTHROUGH;
case COPY: case COPY:
copy = state->length; copy = state->length;
if (copy) { if (copy) {
@@ -1049,10 +1049,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 */ ZFALLTHROUGH;
case LEN_: case LEN_:
state->mode = LEN; state->mode = LEN;
/* FALLTHROUGH */ ZFALLTHROUGH;
case LEN: case LEN:
if (have >= 6 && left >= 258) { if (have >= 6 && left >= 258) {
RESTORE(); RESTORE();
@@ -1102,7 +1102,7 @@ int flush;
} }
state->extra = (unsigned)(here.op) & 15; state->extra = (unsigned)(here.op) & 15;
state->mode = LENEXT; state->mode = LENEXT;
/* FALLTHROUGH */ ZFALLTHROUGH;
case LENEXT: case LENEXT:
if (state->extra) { if (state->extra) {
NEEDBITS(state->extra); NEEDBITS(state->extra);
@@ -1113,7 +1113,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 */ ZFALLTHROUGH;
case DIST: case DIST:
for (;;) { for (;;) {
here = state->distcode[BITS(state->distbits)]; here = state->distcode[BITS(state->distbits)];
@@ -1141,7 +1141,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 */ ZFALLTHROUGH;
case DISTEXT: case DISTEXT:
if (state->extra) { if (state->extra) {
NEEDBITS(state->extra); NEEDBITS(state->extra);
@@ -1158,7 +1158,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 */ ZFALLTHROUGH;
case MATCH: case MATCH:
if (left == 0) goto inf_leave; if (left == 0) goto inf_leave;
copy = out - left; copy = out - left;
@@ -1234,7 +1234,7 @@ int flush;
} }
#ifdef GUNZIP #ifdef GUNZIP
state->mode = LENGTH; state->mode = LENGTH;
/* FALLTHROUGH */ ZFALLTHROUGH;
case LENGTH: case LENGTH:
if (state->wrap && state->flags) { if (state->wrap && state->flags) {
NEEDBITS(32); NEEDBITS(32);
@@ -1248,7 +1248,7 @@ int flush;
} }
#endif #endif
state->mode = DONE; state->mode = DONE;
/* FALLTHROUGH */ ZFALLTHROUGH;
case DONE: case DONE:
ret = Z_STREAM_END; ret = Z_STREAM_END;
goto inf_leave; goto inf_leave;

View File

@@ -9,6 +9,7 @@
#define ZCONF_H #define ZCONF_H
/* The following four defines are enabled by sudo's configure script. */ /* The following four defines are enabled by sudo's configure script. */
#undef HAVE_FALLTHROUGH_ATTRIBUTE
#undef HAVE_DSO_VISIBILITY #undef HAVE_DSO_VISIBILITY
#undef HAVE_MEMCPY #undef HAVE_MEMCPY
#undef HAVE_UNISTD_H #undef HAVE_UNISTD_H
@@ -30,6 +31,12 @@
# endif # endif
#endif #endif
#ifdef HAVE_FALLTHROUGH_ATTRIBUTE
# define ZFALLTHROUGH __attribute__((__fallthrough__))
#else
# define ZFALLTHROUGH do { } while (0)
#endif
/* /*
* If you *really* need a unique prefix for all types and library functions, * If you *really* need a unique prefix for all types and library functions,
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.