From: Willy Tarreau Date: Tue, 17 Nov 2026 08:21:17 +0000 (+0100) Subject: IMPORT: slz-prv: work around lobotomized compilers' fallthrough diagnostics X-Git-Tag: v3.5-dev13~39 X-Git-Url: https://git.kaiwu.me/web/%22data:,/doc/static/%7B@url%7D?a=commitdiff_plain;h=726d2ba132cc7e1019e051f96a8d7e1a5f15956d;p=haproxy.git IMPORT: slz-prv: work around lobotomized compilers' fallthrough diagnostics When preprocessing and compilation run as separate phases (cpp then cc, as often happens in distributed builds for example), comments are stripped before compilation begins. Lobotomized compilers that decide to emit warnings when they don't see "/* fall through */" comment annotations that were dropped on the previous phase were just misdesigned in a hurry and are causing harm. We already had to do this in tables.h in the past but it's just lost at the wrong place now. Let's just move that __fallthrough definition into slz-prv.h where it's easier to locate, and use it in slz_rfc1951_flush() to silence a compiler warning instead of modifying the code to work around this absurdity. This is slz commit 06e2caf45e. --- diff --git a/include/import/slz-prv.h b/include/import/slz-prv.h index 07719bdc0..147b9581c 100644 --- a/include/import/slz-prv.h +++ b/include/import/slz-prv.h @@ -48,6 +48,23 @@ #define HAVE_FAST_MULT #endif +/* This horrible mess is needed to shut up the fallthrough warning since the + * stupid comment approach doesn't resist to separate preprocessing (e.g. as + * used in distcc). Note that compilers which support the fallthrough attribute + * also support __has_attribute. + */ +#ifndef __fallthrough +# ifdef __has_attribute +# if __has_attribute(fallthrough) +# define __fallthrough __attribute__((fallthrough)) +# else +# define __fallthrough do { } while (0) +# endif +# else +# define __fallthrough do { } while (0) +# endif +#endif + /* returns the max of and , must be constant since evaluated twice */ #define MIN_C(a, b) ({ \ (a < b) ? a : b; \ diff --git a/include/import/slz-tables.h b/include/import/slz-tables.h index f5e8f9a73..10f1b4609 100644 --- a/include/import/slz-tables.h +++ b/include/import/slz-tables.h @@ -296,23 +296,6 @@ static const uint8_t text_dist_shift[32] = { 15, 9, 11, 10, 13, 10, 9, 11, 13, 9, 10, 11, 12, 10, 9, 0, }; -/* This horrible mess is needed to shut up the fallthrough warning since the - * stupid comment approach doesn't resist to separate preprocessing (e.g. as - * used in distcc). Note that compilers which support the fallthrough attribute - * also support __has_attribute. - */ -#ifndef __fallthrough -# ifdef __has_attribute -# if __has_attribute(fallthrough) -# define __fallthrough __attribute__((fallthrough)) -# else -# define __fallthrough do { } while (0) -# endif -# else -# define __fallthrough do { } while (0) -# endif -#endif - #if defined(PRECOMPUTE_TABLES) #if !defined(__ARM_FEATURE_CRC32) diff --git a/src/slz.c b/src/slz.c index 5a495d31e..7b853705b 100644 --- a/src/slz.c +++ b/src/slz.c @@ -2610,7 +2610,7 @@ int slz_rfc1951_flush(struct slz_stream *strm, unsigned char *buf) case SLZ_ST_LAST: send_eob(strm, strm->cur_tree); strm->state = SLZ_ST_DONE; - /* fall through */ + __fallthrough; case SLZ_ST_DONE: case SLZ_ST_END: flush_bits(strm);