]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: mux_fcgi: avoid aliasing of a const struct in traces
authorWilly Tarreau <w@1wt.eu>
Fri, 28 Jan 2022 08:36:35 +0000 (09:36 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 28 Jan 2022 18:04:02 +0000 (19:04 +0100)
fcgi_trace() declares fconn as a const and casts its mbuf array to
(struct buffer*), which rightfully upsets some older compilers. Better
just declare it as a writable variable and get rid of the cast. It's
harmless anyway. This has been there since 2.1 with commit 5c0f859c2
("MINOR: mux-fcgi/trace: Register a new trace source with its events")
and doens't need to be backported though it would not harm either.

src/mux_fcgi.c

index ba3a5461772935d57a48cec4afc88aa61a793d63..fa9e3adb96757a1b5740cd3466cb84bbfb449565 100644 (file)
@@ -425,7 +425,7 @@ static void fcgi_trace(enum trace_level level, uint64_t mask, const struct trace
                       const void *a1, const void *a2, const void *a3, const void *a4)
 {
        const struct connection *conn = a1;
-       const struct fcgi_conn *fconn = conn ? conn->ctx : NULL;
+       struct fcgi_conn *fconn = conn ? conn->ctx : NULL;
        const struct fcgi_strm *fstrm = a2;
        const struct htx *htx = a3;
        const size_t     *val = a4;
@@ -482,8 +482,8 @@ static void fcgi_trace(enum trace_level level, uint64_t mask, const struct trace
                                      (unsigned int)b_head_ofs(&fconn->dbuf), (unsigned int)b_size(&fconn->dbuf));
                if (src->verbosity == FCGI_VERB_COMPLETE ||
                    (src->verbosity == FCGI_VERB_ADVANCED && (mask & (FCGI_EV_FCONN_SEND|FCGI_EV_TX_RECORD)))) {
-                       struct buffer *hmbuf = br_head((struct buffer *)fconn->mbuf);
-                       struct buffer *tmbuf = br_tail((struct buffer *)fconn->mbuf);
+                       struct buffer *hmbuf = br_head(fconn->mbuf);
+                       struct buffer *tmbuf = br_tail(fconn->mbuf);
 
                        chunk_appendf(&trace_buf, " .mbuf=[%u..%u|%u],h=[%u@%p+%u/%u],t=[%u@%p+%u/%u]",
                                      br_head_idx(fconn->mbuf), br_tail_idx(fconn->mbuf), br_size(fconn->mbuf),