]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: cache: fix a build warning with gcc < 7
authorWilly Tarreau <w@1wt.eu>
Wed, 17 Apr 2024 07:36:33 +0000 (09:36 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 17 Apr 2024 07:43:32 +0000 (09:43 +0200)
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

index caa072ff22ff9faed310eb84e2260522faffb2b7..4a9992a19c731d362163457cf0d7ef21cc74ba11 100644 (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)