From 080044c7f2754684b37b9abc5d862d3f9757f893 Mon Sep 17 00:00:00 2001 From: Yannis Guyon Date: Thu, 9 Apr 2026 08:58:49 +0000 Subject: [PATCH] Replace [[fallthrough]] with WEBP_FALLTHROUGH C and C++ version values based on https://en.cppreference.com/w/c/23.html and https://en.cppreference.com/w/cpp/preprocessor/replace. Change-Id: I1059fa9e17f25f05d452f8dd003ca7d421742bf7 --- examples/webpmux.c | 12 +++++++++--- src/webp/types.h | 9 +++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/examples/webpmux.c b/examples/webpmux.c index 8f32914d..d5c71af6 100644 --- a/examples/webpmux.c +++ b/examples/webpmux.c @@ -493,12 +493,18 @@ static int ParseFrameArgs(const char* args, WebPMuxFrameInfo* const info) { &plus_minus, &blend_method, &unused); switch (num_args) { case 1: - info->x_offset = info->y_offset = 0; // fall through + info->x_offset = info->y_offset = 0; + WEBP_FALLTHROUGH; + // fall through case 3: - dispose_method = 0; // fall through + dispose_method = 0; + WEBP_FALLTHROUGH; + // fall through case 4: plus_minus = '+'; - blend_method = 'b'; // fall through + blend_method = 'b'; + WEBP_FALLTHROUGH; + // fall through case 6: break; case 2: diff --git a/src/webp/types.h b/src/webp/types.h index 9521c863..8b086a1c 100644 --- a/src/webp/types.h +++ b/src/webp/types.h @@ -71,6 +71,15 @@ typedef long long int int64_t; #endif /* defined(_WIN32) && defined(WEBP_DLL) */ #endif /* WEBP_EXTERN */ +#ifndef WEBP_FALLTHROUGH +#if (defined(__cplusplus) && __cplusplus >= 201703L) || \ + (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) +#define WEBP_FALLTHROUGH [[fallthrough]] +#else +#define WEBP_FALLTHROUGH +#endif +#endif /* WEBP_FALLTHROUGH */ + // Macro to check ABI compatibility (same major revision number) #define WEBP_ABI_IS_INCOMPATIBLE(a, b) (((a) >> 8) != ((b) >> 8))