Skip to content

Commit 2b9665c

Browse files
peffgitster
authored andcommitted
convert: add const to fix strchr() warnings
C23 versions of libc (like recent glibc) may provide generic versions of strchr() that match constness between the input and return value. The idea being that the compiler can detect when it implicitly converts a const pointer into a non-const one (which then emits a warning). There are a few cases here where the result pointer does not need to be non-const at all, and we should mark it as such. That silences the warning (and avoids any potential problems with trying to write via those pointers). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 270e10a commit 2b9665c

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

convert.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,8 @@ static int ident_to_worktree(const char *src, size_t len,
11681168
struct strbuf *buf, int ident)
11691169
{
11701170
struct object_id oid;
1171-
char *to_free = NULL, *dollar, *spc;
1171+
char *to_free = NULL;
1172+
const char *dollar, *spc;
11721173
int cnt;
11731174

11741175
if (!ident)

0 commit comments

Comments
 (0)