From f66d79b8b2567a9ab29ff31fc842834fc15d2b3f Mon Sep 17 00:00:00 2001 From: Jim Jagielski Date: Thu, 24 Nov 2011 15:53:16 +0000 Subject: [PATCH] Use varargs... git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1205894 13f79535-47bb-0310-9956-ffa450edef68 --- include/util_filter.h | 9 +++++---- modules/cache/mod_cache.c | 11 ++++------- server/util_filter.c | 18 +++++++++++++----- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/include/util_filter.h b/include/util_filter.h index 4b4236529f..cc2a0f76e3 100644 --- a/include/util_filter.h +++ b/include/util_filter.h @@ -322,8 +322,8 @@ AP_DECLARE(apr_status_t) ap_pass_brigade(ap_filter_t *filter, * ::HTTP_INTERNAL_SERVER_ERROR on all other errors * @param r The request rec * @param bucket The current bucket brigade - * @param msg Optional error msg; if NULL defaults to "ap_pass_brigade returned" - * + * @param fmt The format string. If NULL defaults to "ap_pass_brigade returned" + * @param ... The arguments to use to fill out the format string * @remark Ownership of the brigade is retained by the caller. On return, * the contents of the brigade are UNDEFINED, and the caller must * either call apr_brigade_cleanup or apr_brigade_destroy on @@ -331,7 +331,8 @@ AP_DECLARE(apr_status_t) ap_pass_brigade(ap_filter_t *filter, */ AP_DECLARE(apr_status_t) ap_pass_brigade_fchk(request_rec *r, apr_bucket_brigade *bucket, - const char *msg); + const char *fmt, + ...); /** @@ -574,7 +575,7 @@ AP_DECLARE_NONSTD(apr_status_t) ap_fputstrs(ap_filter_t *f, * @param f the filter we are writing to * @param bb The brigade to buffer into * @param fmt The format string - * @param ... The argumets to use to fill out the format string + * @param ... The arguments to use to fill out the format string */ AP_DECLARE_NONSTD(apr_status_t) ap_fprintf(ap_filter_t *f, apr_bucket_brigade *bb, diff --git a/modules/cache/mod_cache.c b/modules/cache/mod_cache.c index 6b4e13e8a6..b95ded506a 100644 --- a/modules/cache/mod_cache.c +++ b/modules/cache/mod_cache.c @@ -294,9 +294,8 @@ static int cache_quick_handler(request_rec *r, int lookup) APR_BRIGADE_INSERT_TAIL(out, e); return ap_pass_brigade_fchk(r, out, - apr_psprintf(r->pool, - "cache_quick_handler(%s): ap_pass_brigade returned", - cache->provider_name)); + "cache_quick_handler(%s): ap_pass_brigade returned", + cache->provider_name); } /** @@ -568,10 +567,8 @@ static int cache_handler(request_rec *r) out = apr_brigade_create(r->pool, r->connection->bucket_alloc); e = apr_bucket_eos_create(out->bucket_alloc); APR_BRIGADE_INSERT_TAIL(out, e); - return ap_pass_brigade_fchk(r, out, - apr_psprintf(r->pool, - "cache(%s): ap_pass_brigade returned", - cache->provider_name)); + return ap_pass_brigade_fchk(r, out, "cache(%s): ap_pass_brigade returned", + cache->provider_name); } /* diff --git a/server/util_filter.c b/server/util_filter.c index fd07145dbb..74dfefba10 100644 --- a/server/util_filter.c +++ b/server/util_filter.c @@ -544,17 +544,25 @@ AP_DECLARE(apr_status_t) ap_pass_brigade(ap_filter_t *next, */ AP_DECLARE(apr_status_t) ap_pass_brigade_fchk(request_rec *r, apr_bucket_brigade *bb, - const char *errmsg) + const char *fmt, + ...) { apr_status_t rv; - if (!errmsg) - errmsg = "ap_pass_brigade returned"; rv = ap_pass_brigade(r->output_filters, bb); if (rv != APR_SUCCESS) { if (rv != AP_FILTER_ERROR) { - ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, r, - "%s %d", errmsg, rv); + if (!fmt) + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, r, + "ap_pass_brigade returned %d", rv); + else { + va_list ap; + const char *res; + va_start(ap, fmt); + res = apr_pvsprintf(r->pool, fmt, ap); + va_end(ap); + ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, r, res, NULL); + } return HTTP_INTERNAL_SERVER_ERROR; } return AP_FILTER_ERROR; -- 2.40.0