From 5a0f900569f421422bd7511a45c7346c7668e710 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Mon, 4 May 2026 23:03:22 +0200 Subject: global: fix libc constness warnings Signed-off-by: Jason A. Donenfeld --- filter.c | 2 +- parsing.c | 8 +++++--- shared.c | 3 ++- ui-blame.c | 2 +- ui-plain.c | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/filter.c b/filter.c index cb01d32..c778d05 100644 --- a/filter.c +++ b/filter.c @@ -402,7 +402,7 @@ static const struct { struct cgit_filter *cgit_new_filter(const char *cmd, filter_type filtertype) { - char *colon; + const char *colon; int i; size_t len; int argument_count; diff --git a/parsing.c b/parsing.c index 115ce81..bdaed25 100644 --- a/parsing.c +++ b/parsing.c @@ -19,7 +19,7 @@ */ void cgit_parse_url(const char *url) { - char *c, *cmd, *p; + char *c, *cmd, *p, *buf; struct cgit_repo *repo; if (!url || url[0] == '\0') @@ -32,11 +32,12 @@ void cgit_parse_url(const char *url) return; } + buf = xstrdup(url); cmd = NULL; - c = strchr(url, '/'); + c = strchr(buf, '/'); while (c) { c[0] = '\0'; - repo = cgit_get_repoinfo(url); + repo = cgit_get_repoinfo(buf); if (repo) { ctx.repo = repo; cmd = c; @@ -56,6 +57,7 @@ void cgit_parse_url(const char *url) if (cmd[1]) ctx.qry.page = xstrdup(cmd + 1); } + free(buf); } static char *substr(const char *head, const char *tail) diff --git a/shared.c b/shared.c index 8173eb8..a39394d 100644 --- a/shared.c +++ b/shared.c @@ -551,7 +551,8 @@ char *expand_macros(const char *txt) char *get_mimetype_for_filename(const char *filename) { - char *ext, *mimetype, line[1024]; + const char *ext; + char *mimetype, line[1024]; struct string_list list = STRING_LIST_INIT_NODUP; int i; FILE *file; diff --git a/ui-blame.c b/ui-blame.c index 9c575ef..5c6f36e 100644 --- a/ui-blame.c +++ b/ui-blame.c @@ -263,7 +263,7 @@ static int walk_tree(const struct object_id *oid, struct strbuf *base, static int basedir_len(const char *path) { - char *p = strrchr(path, '/'); + const char *p = strrchr(path, '/'); if (p) return p - path + 1; return 0; diff --git a/ui-plain.c b/ui-plain.c index 0301439..a2a4087 100644 --- a/ui-plain.c +++ b/ui-plain.c @@ -157,7 +157,7 @@ static int walk_tree(const struct object_id *oid, struct strbuf *base, static int basedir_len(const char *path) { - char *p = strrchr(path, '/'); + const char *p = strrchr(path, '/'); if (p) return p - path + 1; return 0; -- cgit v1.2.3