From: Willy Tarreau Date: Wed, 17 Apr 2024 07:36:33 +0000 (+0200) Subject: BUILD: cache: fix a build warning with gcc < 7 X-Git-Tag: v3.0-dev8~37 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1c944eab08458b220861da4c17d32858534be6b2;p=thirdparty%2Fhaproxy.git 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. --- 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)