From 821b552305b2afccee092ac08863ba4058badc72 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Fri, 16 Oct 2026 06:21:33 -1000 Subject: Keep string literals behind const pointers Git's DEVELOPER=1 build turns on -Wwrite-strings as an error, and the literals stored through plain char pointers failed cgit's own objects there. The exec filter's argv takes the cast execvp needs once, the way git's run-command does. --- source/ui-shared.c | 41 +++++++++++++++++------------------------ 1 file changed, 17 insertions(+), 24 deletions(-) (limited to 'source/ui-shared.c') diff --git a/source/ui-shared.c b/source/ui-shared.c index e5afb2e..b88edec 100644 --- a/source/ui-shared.c +++ b/source/ui-shared.c @@ -343,36 +343,26 @@ static void print_rel_vcs_link(const char *url) html(" Git repository'>\n"); } -static int emit_css_link(struct string_list_item *item, void *fallback) +static void emit_css_link(const char *href) { // An empty css entry is how a site turns the stylesheet off. - if (item && *item->string == '\0') - return 0; + if (!*href) + return; html("\n"); - - return 0; } -static int emit_js_link(struct string_list_item *item, void *fallback) +static void emit_js_link(const char *src) { // An empty js entry is how a site turns the script off. - if (item && *item->string == '\0') - return 0; + if (!*src) + return; html("\n"); - - return 0; } static void add_clone_urls(void (*fn)(const char *), char *urls, char *suffix) @@ -1495,6 +1485,7 @@ void cgit_redirect(const char *url, const char *query, bool permanent) void cgit_print_docstart(void) { const struct object_id *pinned; + struct string_list_item *item; char *host = cgit_hosturl(); if (ctx.cfg.embedded) { @@ -1538,15 +1529,17 @@ void cgit_print_docstart(void) html("'>\n"); } - if (ctx.cfg.css.items) - for_each_string_list(&ctx.cfg.css, emit_css_link, NULL); + if (ctx.cfg.css.nr) + for_each_string_list_item(item, &ctx.cfg.css) + emit_css_link(item->string); else - emit_css_link(NULL, "/cgit.css"); + emit_css_link("/cgit.css"); - if (ctx.cfg.js.items) - for_each_string_list(&ctx.cfg.js, emit_js_link, NULL); + if (ctx.cfg.js.nr) + for_each_string_list_item(item, &ctx.cfg.js) + emit_js_link(item->string); else - emit_js_link(NULL, "/cgit.js"); + emit_js_link("/cgit.js"); if (ctx.cfg.favicon && *ctx.cfg.favicon) { html("