From: Yannik Tausch Date: Thu, 03 Sep 2026 18:44:24 GMT Subject: [PATCH v3 1/3] pathspec: match and original in pathspec_item are const Message-ID: In-Reply-To: <887D6D84-F76E-4DCB-9633-CD78DA02BCC5@ytausch.de> From: Junio C Hamano No existing code modifies these two strings in pathspec elements after they are created via these two pointers. Declare them as "const char *" to stress on this fact and cast away constness from the code that frees these two strings. Signed-off-by: Junio C Hamano Signed-off-by: Yannik Tausch --- pathspec.c | 4 ++-- pathspec.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pathspec.c b/pathspec.c index 281858f21f..41c53ff26e 100644 --- a/pathspec.c +++ b/pathspec.c @@ -749,8 +749,8 @@ void clear_pathspec(struct pathspec *pathspec) int i, j; for (i = 0; i < pathspec->nr; i++) { - free(pathspec->items[i].match); - free(pathspec->items[i].original); + free((void *)pathspec->items[i].match); + free((void *)pathspec->items[i].original); for (j = 0; j < pathspec->items[i].attr_match_nr; j++) free(pathspec->items[i].attr_match[j].value); diff --git a/pathspec.h b/pathspec.h index 5e3a6f1fe7..fc1b9465ad 100644 --- a/pathspec.h +++ b/pathspec.h @@ -35,8 +35,8 @@ struct pathspec { unsigned magic; int max_depth; struct pathspec_item { - char *match; - char *original; + const char *match; + const char *original; unsigned magic; int len, prefix; int nowildcard_len; -- 2.55.0