From: Junio C Hamano <gitster@pobox.com>
To: Michael J Gruber <git@grubix.eu>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 3/6] do not discard const: adjust to non-const data types
Date: Thu, 26 Mar 2026 10:28:54 -0700 [thread overview]
Message-ID: <xmqq5x6iqz3d.fsf@gitster.g> (raw)
In-Reply-To: <8a65ada967b6b1308ea4cffca82102d4de8e9dd9.1774537954.git.git@grubix.eu> (Michael J. Gruber's message of "Thu, 26 Mar 2026 16:22:49 +0100")
Michael J Gruber <git@grubix.eu> 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.
next prev parent reply other threads:[~2026-03-26 17:29 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-26 15:22 [PATCH 0/6] ISOC23: quell warnings on discarding const Michael J Gruber
2026-03-26 15:22 ` [PATCH 1/6] do not discard const: the simple cases Michael J Gruber
2026-03-26 17:34 ` Jeff King
2026-03-26 17:45 ` Junio C Hamano
2026-03-26 19:23 ` [PATCH] config: store allocated string in non-const pointer Jeff King
2026-03-26 15:22 ` [PATCH 2/6] do not discard const: make git-compat-util ISOC23-like Michael J Gruber
2026-03-26 15:22 ` [PATCH 3/6] do not discard const: adjust to non-const data types Michael J Gruber
2026-03-26 17:28 ` Junio C Hamano [this message]
2026-03-26 15:22 ` [PATCH 4/6] do not discard const: declare const where we stay const Michael J Gruber
2026-03-26 15:22 ` [PATCH 5/6] do not discard const: keep signature Michael J Gruber
2026-03-26 17:18 ` Junio C Hamano
2026-03-26 15:22 ` [PATCH 6/6] do not discard const: the ugly truth Michael J Gruber
2026-03-26 17:07 ` Junio C Hamano
2026-03-26 17:42 ` Jeff King
2026-03-26 19:02 ` [PATCH 0/4] fix const issues in revision parser Jeff King
2026-03-26 19:04 ` [PATCH 1/4] revision: make handle_dotdot() interface less confusing Jeff King
2026-03-26 19:28 ` Junio C Hamano
2026-03-26 23:14 ` Jeff King
2026-03-27 15:55 ` Junio C Hamano
2026-03-26 19:05 ` [PATCH 2/4] rev-parse: simplify dotdot parsing Jeff King
2026-03-26 19:13 ` [PATCH 3/4] revision: avoid writing to const string for parent marks Jeff King
2026-03-26 19:14 ` [PATCH 4/4] rev-parse: " Jeff King
2026-03-26 16:26 ` [PATCH 0/6] ISOC23: quell warnings on discarding const D. Ben Knoble
2026-03-27 17:45 ` Michael J Gruber
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq5x6iqz3d.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@grubix.eu \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox