From: Junio C Hamano Date: Thu, 26 Mar 2026 17:28:54 GMT Subject: Re: [PATCH 3/6] do not discard const: adjust to non-const data types Message-ID: In-Reply-To: <8a65ada967b6b1308ea4cffca82102d4de8e9dd9.1774537954.git.git@grubix.eu> Michael J Gruber writes: > We use data types (such as string_list's util member) which are not > necessarily "non-const in practice" (such as the list of environment > variables in run-command.c) but are not declared "const". Rather than > duplicating data types (e.g. with a new constr_string_list), discard the > const explicitly for now to quell ISOC23 warnings. > --- > http-push.c | 2 +- > run-command.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/http-push.c b/http-push.c > index 9ae6062198..acc7f1d8fa 100644 > --- a/http-push.c > +++ b/http-push.c > @@ -1772,7 +1772,7 @@ int cmd_main(int argc, const char **argv) > str_end_url_with_slash(arg, &repo->url); > repo->path_len = strlen(repo->url); > if (path) { > - repo->path = strchr(path+2, '/'); > + repo->path = (char *) strchr(path+2, '/'); > if (repo->path) > repo->path_len = strlen(repo->path); > } > diff --git a/run-command.c b/run-command.c > index 32c290ee6a..1db02ef030 100644 > --- a/run-command.c > +++ b/run-command.c > @@ -604,7 +604,7 @@ static void trace_add_env(struct strbuf *dst, const char *const *deltaenv) > /* Last one wins, see run-command.c:prep_childenv() for context */ > for (e = deltaenv; e && *e; e++) { > struct strbuf key = STRBUF_INIT; > - char *equals = strchr(*e, '='); > + char *equals = (char *) strchr(*e, '='); > > if (equals) { > strbuf_add(&key, *e, equals - *e); I didn't look at the other http-push.c one, but this part with a bit wider context reads like this: for (e = deltaenv; e && *e; e++) { struct strbuf key = STRBUF_INIT; char *equals = strchr(*e, '='); if (equals) { strbuf_add(&key, *e, equals - *e); string_list_insert(&envs, key.buf)->util = equals + 1; } else { string_list_insert(&envs, *e)->util = NULL; } strbuf_release(&key); } I wonder if the cast to strip away constness wants to go near the assignment to ->util.