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.
This commit is contained in:
Willy Tarreau 2024-04-17 09:36:33 +02:00
parent 50d8c18742
commit 1c944eab08

View File

@ -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)