Skip to content

Commit 81df4e0

Browse files
peffgitster
authored andcommitted
range-diff: drop const to fix strstr() warnings
This is another case where we implicitly drop the "const" from a pointer by feeding it to strstr() and assigning the result to a non-const pointer. This is OK in practice, since the const pointer originally comes from a writable source (a strbuf), but C23 libc implementations have started to complain about it. We do write to the output pointer, so it needs to remain non-const. We can just switch the input pointer to also be non-const in this case. By itself that would run into problems with calls to skip_prefix(), but since that function has now been taught to match in/out constness automatically, it just works without us doing anything further. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 59b5d98 commit 81df4e0

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

range-diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ static int read_patches(const char *range, struct string_list *list,
8888
line = contents.buf;
8989
size = contents.len;
9090
for (; size > 0; size -= len, line += len) {
91-
const char *p;
91+
char *p;
9292
char *eol;
9393

9494
eol = memchr(line, '\n', size);

0 commit comments

Comments
 (0)