]> granicus.if.org Git - apache/commitdiff
mod_http2: no variadic macro in C89, use equivalent function.
authorYann Ylavic <ylavic@apache.org>
Tue, 22 Mar 2016 20:46:19 +0000 (20:46 +0000)
committerYann Ylavic <ylavic@apache.org>
Tue, 22 Mar 2016 20:46:19 +0000 (20:46 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1736250 13f79535-47bb-0310-9956-ffa450edef68

modules/http2/h2_filter.c

index 92e87bcd17987f02b38adcadc2ec9ca9222ffdbf..c036b02fd4612b051ad83a22f3a638d78c50afa6 100644 (file)
@@ -196,7 +196,18 @@ int h2_filter_h2_status_handler(request_rec *r)
     return DECLINED;
 }
 
-#define bbout(...)   apr_brigade_printf(bb, NULL, NULL, __VA_ARGS__)
+static apr_status_t bbout(apr_bucket_brigade *bb, const char *fmt, ...)
+{
+    va_list args;
+    apr_status_t rv;
+
+    va_start(args, fmt);
+    rv = apr_brigade_vprintf(bb, NULL, NULL, fmt, args);
+    va_end(args);
+
+    return rv;
+}
+
 static apr_status_t h2_sos_h2_status_buffer(h2_sos *sos, apr_bucket_brigade *bb)
 {
     h2_stream *stream = sos->stream;
@@ -209,21 +220,21 @@ static apr_status_t h2_sos_h2_status_buffer(h2_sos *sos, apr_bucket_brigade *bb)
         bb = apr_brigade_create(stream->pool, session->c->bucket_alloc);
     }
     
-    bbout("{\n");
-    bbout("  \"HTTP2\": \"on\",\n");
-    bbout("  \"H2PUSH\": \"%s\",\n", h2_session_push_enabled(session)? "on" : "off");
-    bbout("  \"mod_http2_version\": \"%s\",\n", MOD_HTTP2_VERSION);
-    bbout("  \"session_id\": %ld,\n", (long)session->id);
-    bbout("  \"streams_max\": %d,\n", (int)session->max_stream_count);
-    bbout("  \"this_stream\": %d,\n", stream->id);
-    bbout("  \"streams_open\": %d,\n", (int)h2_ihash_count(session->streams));
-    bbout("  \"max_stream_started\": %d,\n", mplx->max_stream_started);
-    bbout("  \"requests_received\": %d,\n", session->remote.emitted_count);
-    bbout("  \"responses_submitted\": %d,\n", session->responses_submitted);
-    bbout("  \"streams_reset\": %d, \n", session->streams_reset);
-    bbout("  \"pushes_promised\": %d,\n", session->pushes_promised);
-    bbout("  \"pushes_submitted\": %d,\n", session->pushes_submitted);
-    bbout("  \"pushes_reset\": %d,\n", session->pushes_reset);
+    bbout(bb, "{\n");
+    bbout(bb, "  \"HTTP2\": \"on\",\n");
+    bbout(bb, "  \"H2PUSH\": \"%s\",\n", h2_session_push_enabled(session)? "on" : "off");
+    bbout(bb, "  \"mod_http2_version\": \"%s\",\n", MOD_HTTP2_VERSION);
+    bbout(bb, "  \"session_id\": %ld,\n", (long)session->id);
+    bbout(bb, "  \"streams_max\": %d,\n", (int)session->max_stream_count);
+    bbout(bb, "  \"this_stream\": %d,\n", stream->id);
+    bbout(bb, "  \"streams_open\": %d,\n", (int)h2_ihash_count(session->streams));
+    bbout(bb, "  \"max_stream_started\": %d,\n", mplx->max_stream_started);
+    bbout(bb, "  \"requests_received\": %d,\n", session->remote.emitted_count);
+    bbout(bb, "  \"responses_submitted\": %d,\n", session->responses_submitted);
+    bbout(bb, "  \"streams_reset\": %d, \n", session->streams_reset);
+    bbout(bb, "  \"pushes_promised\": %d,\n", session->pushes_promised);
+    bbout(bb, "  \"pushes_submitted\": %d,\n", session->pushes_submitted);
+    bbout(bb, "  \"pushes_reset\": %d,\n", session->pushes_reset);
     
     diary = session->push_diary;
     if (diary) {
@@ -235,7 +246,7 @@ static apr_status_t h2_sos_h2_status_buffer(h2_sos *sos, apr_bucket_brigade *bb)
                                           stream->request->authority, &data, &len);
         if (status == APR_SUCCESS) {
             base64_digest = h2_util_base64url_encode(data, len, stream->pool);
-            bbout("  \"cache_digest\": \"%s\",\n", base64_digest);
+            bbout(bb, "  \"cache_digest\": \"%s\",\n", base64_digest);
         }
         
         /* try the reverse for testing purposes */
@@ -245,15 +256,15 @@ static apr_status_t h2_sos_h2_status_buffer(h2_sos *sos, apr_bucket_brigade *bb)
                                               stream->request->authority, &data, &len);
             if (status == APR_SUCCESS) {
                 base64_digest = h2_util_base64url_encode(data, len, stream->pool);
-                bbout("  \"cache_digest^2\": \"%s\",\n", base64_digest);
+                bbout(bb, "  \"cache_digest^2\": \"%s\",\n", base64_digest);
             }
         }
     }
-    bbout("  \"frames_received\": %ld,\n", (long)session->frames_received);
-    bbout("  \"frames_sent\": %ld,\n", (long)session->frames_sent);
-    bbout("  \"bytes_received\": %"APR_UINT64_T_FMT",\n", session->io.bytes_read);
-    bbout("  \"bytes_sent\": %"APR_UINT64_T_FMT"\n", session->io.bytes_written);
-    bbout("}\n");
+    bbout(bb, "  \"frames_received\": %ld,\n", (long)session->frames_received);
+    bbout(bb, "  \"frames_sent\": %ld,\n", (long)session->frames_sent);
+    bbout(bb, "  \"bytes_received\": %"APR_UINT64_T_FMT",\n", session->io.bytes_read);
+    bbout(bb, "  \"bytes_sent\": %"APR_UINT64_T_FMT"\n", session->io.bytes_written);
+    bbout(bb, "}\n");
     
     return sos->prev->buffer(sos->prev, bb);
 }