]> git.kaiwu.me - haproxy.git/commitdiff
BUILD: compression: silence clang's -Wunused-but-set-global on comp_res_ring
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 27 Nov 2026 14:45:19 +0000 (15:45 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 27 Nov 2026 14:51:04 +0000 (15:51 +0100)
'comp_res_ring' is only read when haproxy is built with SLZ, but it is
unconditionally set by the 'tune.comp.res.ring' parser, so with a zlib-only
or compression-less build, clang 23 reports:

  src/compression.c:334:12: error: variable 'comp_res_ring' set but not used
                        [-Werror,-Wunused-but-set-global]

This is caught by the Fedora rawhide CI (clang 23) which builds with
USE_ZLIB=1. It is not reproducible with older clang releases which do
not implement -Wunused-but-set-global.

Mark the variable __maybe_unused like other variables only used
conditionally. This does not change the behavior: the keyword remains
accepted and ignored on non-SLZ builds.

This should fix the issue #3609.

src/compression.c

index 12dd1a33f0fe3d8399e86e375b11d2a54466ed60..e6638625163bbd4954a8281d50940bff5d598560 100644 (file)
@@ -331,7 +331,7 @@ static int comp_identity_end(struct comp_ctx **comp_ctx)
 
 
 /* "tune.comp.res.ring": rings may be allocated for responses (default) */
-static int comp_res_ring __read_mostly = 1;
+static int comp_res_ring __read_mostly __maybe_unused = 1;
 
 #ifdef USE_SLZ