From 1c944eab08458b220861da4c17d32858534be6b2 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Wed, 17 Apr 2024 09:36:33 +0200 Subject: [PATCH] BUILD: cache: fix a build warning with gcc < 7 Gcc before 7 does really not like direct operations on cast pointers such as "((struct a*)b)->c += d;". It turns our that we have exactly that construct in 3.0 since commit 5baa9ea168 ("MEDIUM: cache: Save body size of cached objects and track it on delivery"). It's generally sufficient to use an intermediary variable such as : "({ (struct a*) _ = b; _; })->c +=d;" but that's ugly. Fortunately DISGUISE() implicitly does something very similar and works fine, so let's use that. No backport is needed. --- src/cache.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cache.c b/src/cache.c index caa072ff22..4a9992a19c 100644 --- a/src/cache.c +++ b/src/cache.c @@ -820,7 +820,8 @@ cache_store_http_payload(struct stream *s, struct filter *filter, struct http_ms goto no_cache; } - ((struct cache_entry *)st->first_block->data)->body_size += data_len; + /* disguise below to shut a warning on */ + DISGUISE((struct cache_entry *)st->first_block->data)->body_size += data_len; ret = shctx_row_data_append(shctx, st->first_block, (unsigned char *)b_head(&trash), b_data(&trash)); if (ret < 0) -- 2.47.3