From a477234b3a526d56047c44f732afd513565d948e Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 31 Oct 2026 13:24:20 -0700 Subject: Fold the va_list error page into its one caller --- source/ui-shared.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'source/ui-shared.c') diff --git a/source/ui-shared.c b/source/ui-shared.c index de23353..a793be1 100644 --- a/source/ui-shared.c +++ b/source/ui-shared.c @@ -718,12 +718,8 @@ static const char *find_last_char(const char *start, const char *end, int c) static void vprint_error(const char *fmt, va_list ap) { - va_list cp; - html("
"); - va_copy(cp, ap); - html_vtxtf(fmt, cp); - va_end(cp); + html_vtxtf(fmt, ap); html("
\n"); } @@ -1537,23 +1533,18 @@ void cgit_print_error_page(int code, const char *msg, const char *fmt, ...) { va_list ap; - va_start(ap, fmt); - cgit_vprint_error_page(code, msg, fmt, ap); - va_end(ap); -} - -void cgit_vprint_error_page(int code, const char *msg, const char *fmt, va_list ap) -{ // An error page describes a condition that may not outlast the slot // holding it. A request naming a commit not yet pushed would cache its // 404 under the never-expiring static ttl and keep serving it after // the push, so the error is rendered straight to the visitor instead. html_flush(); cache_abandon_fill(); + va_start(ap, fmt); // Once the status line is out the error can only join the body under // way, and the page that hit it carries on to its own end. if (ctx.page.headers_sent) { vprint_error(fmt, ap); + va_end(ap); return; } ctx.page.status = code; @@ -1565,6 +1556,7 @@ void cgit_vprint_error_page(int code, const char *msg, const char *fmt, va_list ctx.page.filename = NULL; cgit_print_layout_start(); vprint_error(fmt, ap); + va_end(ap); cgit_print_layout_end(); } -- cgit