aboutsummaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorCollin Funk <collin.funk1@gmail.com>2026-02-05 17:46:09 -0800
committerJunio C Hamano <gitster@pobox.com>2026-02-05 17:52:49 -0800
commit4ac4705afa3ab660e206c2b870bfae2ddb647ffa (patch)
tree491ad0c6da16c043e2c9691fec84e4d5eff7605e /diff.c
parent67ad42147a7acc2af6074753ebd03d904476118f (diff)
downloadgit-4ac4705afa3ab660e206c2b870bfae2ddb647ffa.tar.xz
global: constify some pointers that are not written to
The recent glibc 2.43 release had the following change listed in its NEWS file: For ISO C23, the functions bsearch, memchr, strchr, strpbrk, strrchr, strstr, wcschr, wcspbrk, wcsrchr, wcsstr and wmemchr that return pointers into their input arrays now have definitions as macros that return a pointer to a const-qualified type when the input argument is a pointer to a const-qualified type. When compiling with GCC 15, which defaults to -std=gnu23, this causes many warnings like this: merge-ort.c: In function ‘apply_directory_rename_modifications’: merge-ort.c:2734:36: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] 2734 | char *last_slash = strrchr(cur_path, '/'); | ^~~~~~~ This patch fixes the more obvious ones by making them const when we do not write to the returned pointer. Signed-off-by: Collin Funk <collin.funk1@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/diff.c b/diff.c
index a68ddd2168..2d92665159 100644
--- a/diff.c
+++ b/diff.c
@@ -1961,7 +1961,7 @@ static int fn_out_diff_words_write_helper(struct diff_options *o,
struct strbuf sb = STRBUF_INIT;
while (count) {
- char *p = memchr(buf, '\n', count);
+ const char *p = memchr(buf, '\n', count);
if (print)
strbuf_addstr(&sb, diff_line_prefix(o));
@@ -3049,7 +3049,7 @@ static long gather_dirstat(struct diff_options *opt, struct dirstat_dir *dir,
struct dirstat_file *f = dir->files;
int namelen = strlen(f->name);
unsigned long changes;
- char *slash;
+ const char *slash;
if (namelen < baselen)
break;