]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: stream: use const filters in the dump function
authorWilly Tarreau <w@1wt.eu>
Fri, 29 Sep 2023 06:43:51 +0000 (08:43 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 29 Sep 2023 07:20:27 +0000 (09:20 +0200)
The strm_dump_to_buffer() function requires a variable stream only
for a few functions in it that do not take a const. strm_flt() is
one of them (and for good reasons since most call places want to
update filters). Here we know we won't modify the filter nor the
stream so let's directly access the strm_flt in the stream and assign
it to a const filter. This will also catch any future accidental change.

src/stream.c

index 6696240bb0e06b8250fe17dd433a333279bb42ee..b69aa2c45a679b2f666764c67badacbc22e9cf91 100644 (file)
@@ -3496,8 +3496,8 @@ static void strm_dump_to_buffer(struct stream *strm, uint32_t anon_key)
                              (htx->tail >= htx->head) ? "NO" : "YES",
                              (unsigned long long)htx->extra);
        }
-       if (HAS_FILTERS(strm) && strm_flt(strm)->current[0]) {
-               struct filter *flt = strm_flt(strm)->current[0];
+       if (HAS_FILTERS(strm) && strm->strm_flt.current[0]) {
+               const struct filter *flt = strm->strm_flt.current[0];
 
                chunk_appendf(&trash, "      current_filter=%p (id=\"%s\" flags=0x%x pre=0x%x post=0x%x) \n",
                              flt, flt->config->id, flt->flags, flt->pre_analyzers, flt->post_analyzers);
@@ -3527,8 +3527,8 @@ static void strm_dump_to_buffer(struct stream *strm, uint32_t anon_key)
                              (htx->tail >= htx->head) ? "NO" : "YES",
                              (unsigned long long)htx->extra);
        }
-       if (HAS_FILTERS(strm) && strm_flt(strm)->current[1]) {
-               struct filter *flt = strm_flt(strm)->current[1];
+       if (HAS_FILTERS(strm) && strm->strm_flt.current[1]) {
+               const struct filter *flt = strm->strm_flt.current[1];
 
                chunk_appendf(&trash, "      current_filter=%p (id=\"%s\" flags=0x%x pre=0x%x post=0x%x) \n",
                              flt, flt->config->id, flt->flags, flt->pre_analyzers, flt->post_analyzers);