[PATCH v2 03/12] transport-helper: drop const to fix strchr() warnings
- From
Jeff King <peff@peff.net>
- Date
- Apr 2, 2026, 04:14 UTC
- Message-ID
- <20260402041456.GC3501239@coredump.intra.peff.net>
- In-Reply-To
- <20260402041433.GA3501120@coredump.intra.peff.net>
We implicitly drop the const from our "key" variable when we do:
char *p = strchr(key, ' ');
which causes compilation with some C23 versions of libc (notably recent glibc) to complain.
We need "p" to remain writable, since we assign NUL over the space we found. We can solve this by also making "key" writable. This works because it comes from a strbuf, which is itself a writable string.
Signed-off-by: Jeff King <peff@peff.net> --- transport-helper.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/transport-helper.c b/transport-helper.c index 4d95d84f9e..4614036c99 100644 --- a/transport-helper.c +++ b/transport-helper.c @@ -781,7 +781,8 @@ static int push_update_ref_status(struct strbuf *buf, if (starts_with(buf->buf, "option ")) { struct object_id old_oid, new_oid; - const char *key, *val; + char *key; + const char *val; char *p; if (!state->hint || !(state->report || state->new_report))
-- 2.53.0.1172.ge9e20b5838