From 1a01ee47403ca5c8684f1ba33b2f679716b607ba Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 29 Sep 2023 08:43:51 +0200 Subject: [PATCH] CLEANUP: stream: use const filters in the dump function 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 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/stream.c b/src/stream.c index 6696240bb..b69aa2c45 100644 --- a/src/stream.c +++ b/src/stream.c @@ -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);