]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: log: make parse_logformat_string() take a const char *
authorWilly Tarreau <w@1wt.eu>
Mon, 24 Dec 2012 11:36:33 +0000 (12:36 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 24 Dec 2012 11:36:33 +0000 (12:36 +0100)
Sometimes we can't pass a char *, and there is no need for this since we strdup() it.

include/proto/log.h
src/log.c

index 173375e4e285e3f880d2c14beb28b2eed810e720..72b9f2b392ffc7475b52af1abe6dc58d2cdf9031 100644 (file)
@@ -70,7 +70,7 @@ void add_to_logformat_list(char *start, char *end, int type, struct list *list_f
  * Variable name are preceded by % and composed by characters [a-zA-Z0-9]* : %varname
  * You can set arguments using { } : %{many arguments}varname
  */
-void parse_logformat_string(char *str, struct proxy *curproxy, struct list *list_format, int capabilities);
+void parse_logformat_string(const char *str, struct proxy *curproxy, struct list *list_format, int capabilities);
 /*
  * Displays the message on stderr with the date and pid. Overrides the quiet
  * mode during startup.
index 1988a1392cf5bebef4632305f1392b1453bc262a..c07b62d6b5bddbd7e62487e9b3866c1dee56bfe9 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -359,9 +359,9 @@ void add_sample_to_logformat_list(char *text, char *arg, int arg_len, struct pro
  *  list_format: the destination list
  *  capabilities: PR_MODE_TCP_ | PR_MODE_HTTP
  */
-void parse_logformat_string(char *fmt, struct proxy *curproxy, struct list *list_format, int capabilities)
+void parse_logformat_string(const char *fmt, struct proxy *curproxy, struct list *list_format, int capabilities)
 {
-       char *sp, *str; /* start pointer for text parts */
+       char *sp, *str, *backfmt; /* start pointer for text parts */
        char *arg = NULL; /* start pointer for args */
        char *var = NULL; /* start pointer for vars */
        int arg_len = 0;
@@ -371,7 +371,7 @@ void parse_logformat_string(char *fmt, struct proxy *curproxy, struct list *list
        struct logformat_node *tmplf, *back;
        int options = 0;
 
-       sp = str = fmt = strdup(fmt);
+       sp = str = backfmt = strdup(fmt);
        curproxy->to_log |= LW_INIT;
 
        /* flush the list first. */
@@ -483,7 +483,7 @@ void parse_logformat_string(char *fmt, struct proxy *curproxy, struct list *list
        if (pformat == LF_STARTVAR || pformat == LF_STARG || pformat == LF_STEXPR)
                Warning("Ignoring end of truncated log-format line after '%s'\n", var ? var : arg ? arg : "%");
 
-       free(fmt);
+       free(backfmt);
 }
 
 /*