lib: Fix fall-through warnings for Clang
In preparation to enable -Wimplicit-fallthrough for Clang, fix multiple warnings by explicitly adding multiple break statements instead of letting the code fall through to the next case, and by replacing a number of /* fall through */ comments with the new pseudo-keyword macro fallthrough. Notice that Clang doesn't recognize /* Fall through */ comments as implicit fall-through markings. Link: https://github.com/KSPP/linux/issues/115 Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
This commit is contained in:
parent
aa60ec0163
commit
314c35f2c9
7 changed files with 18 additions and 13 deletions
|
@ -153,6 +153,7 @@ unsigned long long memparse(const char *ptr, char **retptr)
|
||||||
case 'k':
|
case 'k':
|
||||||
ret <<= 10;
|
ret <<= 10;
|
||||||
endptr++;
|
endptr++;
|
||||||
|
fallthrough;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -363,6 +363,7 @@ int kstrtobool(const char *s, bool *res)
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -434,7 +434,7 @@ static int validate_nla(const struct nlattr *nla, int maxtype,
|
||||||
err = -EINVAL;
|
err = -EINVAL;
|
||||||
goto out_err;
|
goto out_err;
|
||||||
}
|
}
|
||||||
/* fall through */
|
fallthrough;
|
||||||
|
|
||||||
case NLA_STRING:
|
case NLA_STRING:
|
||||||
if (attrlen < 1)
|
if (attrlen < 1)
|
||||||
|
|
|
@ -2530,6 +2530,7 @@ qualifier:
|
||||||
case 'd':
|
case 'd':
|
||||||
case 'i':
|
case 'i':
|
||||||
spec->flags |= SIGN;
|
spec->flags |= SIGN;
|
||||||
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -396,7 +396,7 @@ int zlib_inflate(z_streamp strm, int flush)
|
||||||
strm->adler = state->check = REVERSE(hold);
|
strm->adler = state->check = REVERSE(hold);
|
||||||
INITBITS();
|
INITBITS();
|
||||||
state->mode = DICT;
|
state->mode = DICT;
|
||||||
/* fall through */
|
fallthrough;
|
||||||
case DICT:
|
case DICT:
|
||||||
if (state->havedict == 0) {
|
if (state->havedict == 0) {
|
||||||
RESTORE();
|
RESTORE();
|
||||||
|
@ -404,10 +404,10 @@ int zlib_inflate(z_streamp strm, int flush)
|
||||||
}
|
}
|
||||||
strm->adler = state->check = zlib_adler32(0L, NULL, 0);
|
strm->adler = state->check = zlib_adler32(0L, NULL, 0);
|
||||||
state->mode = TYPE;
|
state->mode = TYPE;
|
||||||
/* fall through */
|
fallthrough;
|
||||||
case TYPE:
|
case TYPE:
|
||||||
if (flush == Z_BLOCK) goto inf_leave;
|
if (flush == Z_BLOCK) goto inf_leave;
|
||||||
/* fall through */
|
fallthrough;
|
||||||
case TYPEDO:
|
case TYPEDO:
|
||||||
INFLATE_TYPEDO_HOOK(strm, flush);
|
INFLATE_TYPEDO_HOOK(strm, flush);
|
||||||
if (state->last) {
|
if (state->last) {
|
||||||
|
@ -446,7 +446,7 @@ int zlib_inflate(z_streamp strm, int flush)
|
||||||
state->length = (unsigned)hold & 0xffff;
|
state->length = (unsigned)hold & 0xffff;
|
||||||
INITBITS();
|
INITBITS();
|
||||||
state->mode = COPY;
|
state->mode = COPY;
|
||||||
/* fall through */
|
fallthrough;
|
||||||
case COPY:
|
case COPY:
|
||||||
copy = state->length;
|
copy = state->length;
|
||||||
if (copy) {
|
if (copy) {
|
||||||
|
@ -480,7 +480,7 @@ int zlib_inflate(z_streamp strm, int flush)
|
||||||
#endif
|
#endif
|
||||||
state->have = 0;
|
state->have = 0;
|
||||||
state->mode = LENLENS;
|
state->mode = LENLENS;
|
||||||
/* fall through */
|
fallthrough;
|
||||||
case LENLENS:
|
case LENLENS:
|
||||||
while (state->have < state->ncode) {
|
while (state->have < state->ncode) {
|
||||||
NEEDBITS(3);
|
NEEDBITS(3);
|
||||||
|
@ -501,7 +501,7 @@ int zlib_inflate(z_streamp strm, int flush)
|
||||||
}
|
}
|
||||||
state->have = 0;
|
state->have = 0;
|
||||||
state->mode = CODELENS;
|
state->mode = CODELENS;
|
||||||
/* fall through */
|
fallthrough;
|
||||||
case CODELENS:
|
case CODELENS:
|
||||||
while (state->have < state->nlen + state->ndist) {
|
while (state->have < state->nlen + state->ndist) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -575,7 +575,7 @@ int zlib_inflate(z_streamp strm, int flush)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
state->mode = LEN;
|
state->mode = LEN;
|
||||||
/* fall through */
|
fallthrough;
|
||||||
case LEN:
|
case LEN:
|
||||||
if (have >= 6 && left >= 258) {
|
if (have >= 6 && left >= 258) {
|
||||||
RESTORE();
|
RESTORE();
|
||||||
|
@ -615,7 +615,7 @@ int zlib_inflate(z_streamp strm, int flush)
|
||||||
}
|
}
|
||||||
state->extra = (unsigned)(this.op) & 15;
|
state->extra = (unsigned)(this.op) & 15;
|
||||||
state->mode = LENEXT;
|
state->mode = LENEXT;
|
||||||
/* fall through */
|
fallthrough;
|
||||||
case LENEXT:
|
case LENEXT:
|
||||||
if (state->extra) {
|
if (state->extra) {
|
||||||
NEEDBITS(state->extra);
|
NEEDBITS(state->extra);
|
||||||
|
@ -623,7 +623,7 @@ int zlib_inflate(z_streamp strm, int flush)
|
||||||
DROPBITS(state->extra);
|
DROPBITS(state->extra);
|
||||||
}
|
}
|
||||||
state->mode = DIST;
|
state->mode = DIST;
|
||||||
/* fall through */
|
fallthrough;
|
||||||
case DIST:
|
case DIST:
|
||||||
for (;;) {
|
for (;;) {
|
||||||
this = state->distcode[BITS(state->distbits)];
|
this = state->distcode[BITS(state->distbits)];
|
||||||
|
@ -649,7 +649,7 @@ int zlib_inflate(z_streamp strm, int flush)
|
||||||
state->offset = (unsigned)this.val;
|
state->offset = (unsigned)this.val;
|
||||||
state->extra = (unsigned)(this.op) & 15;
|
state->extra = (unsigned)(this.op) & 15;
|
||||||
state->mode = DISTEXT;
|
state->mode = DISTEXT;
|
||||||
/* fall through */
|
fallthrough;
|
||||||
case DISTEXT:
|
case DISTEXT:
|
||||||
if (state->extra) {
|
if (state->extra) {
|
||||||
NEEDBITS(state->extra);
|
NEEDBITS(state->extra);
|
||||||
|
@ -669,7 +669,7 @@ int zlib_inflate(z_streamp strm, int flush)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
state->mode = MATCH;
|
state->mode = MATCH;
|
||||||
/* fall through */
|
fallthrough;
|
||||||
case MATCH:
|
case MATCH:
|
||||||
if (left == 0) goto inf_leave;
|
if (left == 0) goto inf_leave;
|
||||||
copy = out - left;
|
copy = out - left;
|
||||||
|
@ -720,7 +720,7 @@ int zlib_inflate(z_streamp strm, int flush)
|
||||||
INITBITS();
|
INITBITS();
|
||||||
}
|
}
|
||||||
state->mode = DONE;
|
state->mode = DONE;
|
||||||
/* fall through */
|
fallthrough;
|
||||||
case DONE:
|
case DONE:
|
||||||
ret = Z_STREAM_END;
|
ret = Z_STREAM_END;
|
||||||
goto inf_leave;
|
goto inf_leave;
|
||||||
|
|
|
@ -269,6 +269,7 @@ ZSTD_STATIC size_t BIT_initDStream(BIT_DStream_t *bitD, const void *srcBuffer, s
|
||||||
case 3: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[2]) << 16;
|
case 3: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[2]) << 16;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case 2: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[1]) << 8;
|
case 2: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[1]) << 8;
|
||||||
|
fallthrough;
|
||||||
default:;
|
default:;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|
|
@ -560,6 +560,7 @@ size_t HUF_compress1X_usingCTable(void *dst, size_t dstSize, const void *src, si
|
||||||
case 2: HUF_encodeSymbol(&bitC, ip[n + 1], CTable); HUF_FLUSHBITS_1(&bitC);
|
case 2: HUF_encodeSymbol(&bitC, ip[n + 1], CTable); HUF_FLUSHBITS_1(&bitC);
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case 1: HUF_encodeSymbol(&bitC, ip[n + 0], CTable); HUF_FLUSHBITS(&bitC);
|
case 1: HUF_encodeSymbol(&bitC, ip[n + 0], CTable); HUF_FLUSHBITS(&bitC);
|
||||||
|
fallthrough;
|
||||||
case 0:
|
case 0:
|
||||||
default:;
|
default:;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue