]> git.kaiwu.me - haproxy.git/commitdiff
CLEANUP: Make `lf_expr` parameter of `sess_build_logline_orig()` const
authorTim Duesterhus <tim@bastelstu.be>
Mon, 13 Apr 2026 17:37:26 +0000 (19:37 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 13 Apr 2026 17:59:12 +0000 (19:59 +0200)
Since this is safely possible without making any changes, we can provide this
hint to the compiler.

include/haproxy/log.h
src/log.c

index a635f8b07911e52d859a16232e2b96220cbd1319..966bc94f103b75bfd6e3d5383e4b94b01505b1c5 100644 (file)
@@ -98,11 +98,11 @@ static inline struct log_orig log_orig(enum log_orig_id id, uint16_t flags)
 
 /* build a log line for the session and an optional stream */
 size_t sess_build_logline_orig(struct session *sess, struct stream *s, char *dst, size_t maxsize,
-                            struct lf_expr *lf_expr, struct log_orig orig);
+                            const struct lf_expr *lf_expr, struct log_orig orig);
 
 /* wrapper for sess_build_logline_orig(), uses LOG_ORIG_UNSPEC log origin */
 static inline size_t sess_build_logline(struct session *sess, struct stream *s, char *dst, size_t maxsize,
-                                     struct lf_expr *lf_expr)
+                                     const struct lf_expr *lf_expr)
 {
        return sess_build_logline_orig(sess, s, dst, maxsize, lf_expr,
                                       log_orig(LOG_ORIG_UNSPEC, LOG_ORIG_FL_NONE));
@@ -200,7 +200,7 @@ char * get_format_pid_sep2(int format, size_t *len);
  * Builds a log line for the stream (must be valid).
  */
 static inline size_t build_logline_orig(struct stream *s, char *dst, size_t maxsize,
-                                     struct lf_expr *lf_expr, struct log_orig orig)
+                                     const struct lf_expr *lf_expr, struct log_orig orig)
 {
        return sess_build_logline_orig(strm_sess(s), s, dst, maxsize, lf_expr, orig);
 }
@@ -208,7 +208,7 @@ static inline size_t build_logline_orig(struct stream *s, char *dst, size_t maxs
 /*
  * Wrapper for build_logline_orig, uses LOG_ORIG_UNSPEC log origin
  */
-static inline size_t build_logline(struct stream *s, char *dst, size_t maxsize, struct lf_expr *lf_expr)
+static inline size_t build_logline(struct stream *s, char *dst, size_t maxsize, const struct lf_expr *lf_expr)
 {
        return build_logline_orig(s, dst, maxsize, lf_expr,
                                  log_orig(LOG_ORIG_UNSPEC, LOG_ORIG_FL_NONE));
index 3e56d512d5723b2c4839ed7131ee3d8a49eaaa62..ba2d9d1833ecfbaa5b847167e244e64acf4af97d 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -3886,7 +3886,7 @@ int lf_expr_dup(const struct lf_expr *orig, struct lf_expr *dest)
  * stream is NULL, default values will be assumed for the stream part.
  */
 size_t sess_build_logline_orig(struct session *sess, struct stream *s,
-                            char *dst, size_t maxsize, struct lf_expr *lf_expr,
+                            char *dst, size_t maxsize, const struct lf_expr *lf_expr,
                             struct log_orig log_orig)
 {
        struct lf_buildctx _ctx = {};
@@ -3896,7 +3896,7 @@ size_t sess_build_logline_orig(struct session *sess, struct stream *s,
        struct http_txn *txn;
        const struct strm_logs *logs;
        struct connection *fe_conn, *be_conn;
-       struct list *list_format = &lf_expr->nodes.list;
+       const struct list *list_format = &lf_expr->nodes.list;
        unsigned int s_flags;
        unsigned int uniq_id;
        struct buffer chunk;