]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD/MINOR: trace: fix use of long type in a few printf format strings
authorWilly Tarreau <w@1wt.eu>
Wed, 27 Nov 2019 14:41:31 +0000 (15:41 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 27 Nov 2019 14:45:11 +0000 (15:45 +0100)
Building on a 32-bit platform produces these warnings in trace code:

src/stream.c: In function 'strm_trace':
src/stream.c:226:29: warning: format '%lu' expects argument of type 'long unsigned int', but argument 9 has type 'size_t {aka const unsigned int}' [-Wformat=]
   chunk_appendf(&trace_buf, " req=(%p .fl=0x%08x .ana=0x%08x .exp(r,w,a)=(%u,%u,%u) .o=%lu .tot=%llu .to_fwd=%u)",
                             ^
src/stream.c:229:29: warning: format '%lu' expects argument of type 'long unsigned int', but argument 9 has type 'size_t {aka const unsigned int}' [-Wformat=]
   chunk_appendf(&trace_buf, " res=(%p .fl=0x%08x .ana=0x%08x .exp(r,w,a)=(%u,%u,%u) .o=%lu .tot=%llu .to_fwd=%u)",
                             ^
src/mux_fcgi.c: In function 'fcgi_trace':
src/mux_fcgi.c:443:29: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'size_t {aka const unsigned int}' [-Wformat=]
   chunk_appendf(&trace_buf, " - VAL=%lu", *val);
                             ^
src/mux_h1.c: In function 'h1_trace':
src/mux_h1.c:290:29: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'size_t {aka const unsigned int}' [-Wformat=]
   chunk_appendf(&trace_buf, " - VAL=%lu", *val);
                             ^

Let's just cast the type to long. This should be backported to 2.1.

src/mux_fcgi.c
src/mux_h1.c
src/stream.c

index d2d2dd4307024b153b5f773e33f21eeb66815d0b..c502670df87724e2b58b7048146aad8ccba1721a 100644 (file)
@@ -440,7 +440,7 @@ static void fcgi_trace(enum trace_level level, uint64_t mask, const struct trace
 
        /* Display the value to the 4th argument (level > STATE) */
        if (src->level > TRACE_LEVEL_STATE && val)
-               chunk_appendf(&trace_buf, " - VAL=%lu", *val);
+               chunk_appendf(&trace_buf, " - VAL=%lu", (long)*val);
 
        /* Display status-line if possible (verbosity > MINIMAL) */
        if (src->verbosity > FCGI_VERB_MINIMAL && htx && htx_nbblks(htx)) {
index b548849532ebee6ccb602761643df909cbb59d98..d7e35cd42e05bcc7769129177f4c77cddb3379c4 100644 (file)
@@ -287,7 +287,7 @@ static void h1_trace(enum trace_level level, uint64_t mask, const struct trace_s
 
        /* Display the value to the 4th argument (level > STATE) */
        if (src->level > TRACE_LEVEL_STATE && val)
-               chunk_appendf(&trace_buf, " - VAL=%lu", *val);
+               chunk_appendf(&trace_buf, " - VAL=%lu", (long)*val);
 
        /* Display status-line if possible (verbosity > MINIMAL) */
        if (src->verbosity > H1_VERB_MINIMAL && htx && htx_nbblks(htx)) {
index 2c0d2c895069a439b861c6ed4324f3afe5d7fae5..4efc16bd7b8a042ced8ae539ed04bf33b9d2bef3 100644 (file)
@@ -225,10 +225,10 @@ static void strm_trace(enum trace_level level, uint64_t mask, const struct trace
        else {
                chunk_appendf(&trace_buf, " req=(%p .fl=0x%08x .ana=0x%08x .exp(r,w,a)=(%u,%u,%u) .o=%lu .tot=%llu .to_fwd=%u)",
                              req, req->flags, req->analysers, req->rex, req->wex, req->analyse_exp,
-                             req->output, req->total, req->to_forward);
+                             (long)req->output, req->total, req->to_forward);
                chunk_appendf(&trace_buf, " res=(%p .fl=0x%08x .ana=0x%08x .exp(r,w,a)=(%u,%u,%u) .o=%lu .tot=%llu .to_fwd=%u)",
                              res, res->flags, res->analysers, res->rex, res->wex, res->analyse_exp,
-                             res->output, res->total, res->to_forward);
+                             (long)res->output, res->total, res->to_forward);
        }
 
        if (src->verbosity == STRM_VERB_SIMPLE ||