Skip to contentSkip to conversation

lib: zstd: bitstream: Mark expected switch fall-throughs

PATCH In review Gustavo A. R. Silva 2 participants 2 messages Nov 28, 2017 Zstd

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib: zstd: bitstream: Mark expected switch fall-throughs

In preparation to enabling -Wimplicit-fallthrough, mark switch cases where we are expecting to fall through.

---
 lib/zstd/bitstream.h | 6 ++++++
 1 file changed, 6 insertions(+)
lib/zstd/bitstream.h +6 -0
index a826b99..18d8200 100644
@@ -259,11 +259,17 @@ ZSTD_STATIC size_t BIT_initDStream(BIT_DStream_t *bitD, const void *srcBuffer, s
 		bitD->bitContainer = *(const BYTE *)(bitD->start);
 		switch (srcSize) {
 		case 7: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[6]) << (sizeof(bitD->bitContainer) * 8 - 16);
+			/* fall through */
 		case 6: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[5]) << (sizeof(bitD->bitContainer) * 8 - 24);
+			/* fall through */
 		case 5: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[4]) << (sizeof(bitD->bitContainer) * 8 - 32);
+			/* fall through */
 		case 4: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[3]) << 24;
+			/* fall through */
 		case 3: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[2]) << 16;
+			/* fall through */
 		case 2: bitD->bitContainer += (size_t)(((const BYTE *)(srcBuffer))[1]) << 8;
+			/* fall through */
 		default:;
 		}
 		{
Signature · 1 line
2.7.4
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Gustavo A. R. Silva

In preparation to enabling -Wimplicit-fallthrough, mark switch cases where we are expecting to fall through.

Looks good to me. We had the same patch in upstream PR#690 [1]. I believe that PR#695 [2] was also necessary to quiet the warning.

[1] https://github.com/facebook/zstd/pull/690/files
[2] https://github.com/facebook/zstd/pull/695/files