From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Cc: Collin Funk <collin.funk1@gmail.com>, Michael J Gruber <git@grubix.eu>
Subject: [PATCH 0/12] fixing the remainder of the C23 strchr warnings
Date: Tue, 31 Mar 2026 19:38:56 -0400 [thread overview]
Message-ID: <20260331233856.GA2327197@coredump.intra.peff.net> (raw)
This series fixes the rest of the warnings you might see on recent glibc
or other C23 libc where:
const char *in = ...;
char *out = strchr(in, ...);
now complains instead of quietly assigning the const pointer to a
non-const one. It's all textually independent of the other fixes, but
if you want a clean build you'll need the others. I think Collin's fixes
have hit master already, but my jk/c23-const-preserving-fixes are still
slated for 'next'.
Some of my fixes are similar to what Michael posted in:
https://lore.kernel.org/git/cover.1774537954.git.git@grubix.eu/
but for most of them I took a somewhat different approach. So this would
be applied instead of those patches.
The patches are:
[01/12]: convert: add const to fix strchr() warnings
[02/12]: http: add const to fix strchr() warnings
[03/12]: transport-helper: drop const to fix strchr() warnings
These ones are obvious fixes that just match the type declarations
to their uses.
[04/12]: pager: explicitly cast away strchr() constness
[05/12]: run-command: explicitly cast away constness when assigning to void
These are ones where I think an explicit cast is the least-bad
option.
[06/12]: find_last_dir_sep(): convert inline function to macro
This is the one that gets repeated a zillion times when you build
because it's in a header file. ;) It takes a slightly different
approach than Collin's in:
https://lore.kernel.org/git/e6f7e2eddbc9aef1c21f661420a4b8cb9cd8e2c1.1770095829.git.collin.funk1@gmail.com/
which I think reduces the fallout through the rest of the codebase.
[07/12]: pseudo-merge: fix disk reads from find_pseudo_merge()
This one is...spicy. I think there are probably actual bugs here,
but my hope is that this takes us in the right direction (and shuts
up the warning).
[08/12]: skip_prefix(): check const match between in and out params
And here is where we might get controversial. It introduces some
macro hackery that makes it safe and easy to use skip_prefix() with
const or non-const strings. I _think_ it should just work
everywhere, but I won't be surprised if some compiler somewhere
complains about the construct. Coverity does, but it is so full of
false positives that adding more is not a big deal.
[09/12]: pkt-line: make packet_reader.line non-const
[10/12]: range-diff: drop const to fix strstr() warnings
[11/12]: http: drop const to fix strstr() warning
[12/12]: refs/files-backend: drop const to fix strchr() warning
And then these are all obvious fixes that are only made possible by
the skip_prefix() magic above. Well, possible without extra ugly
casts everywhere.
builtin/config.c | 7 ++++---
builtin/rev-parse.c | 40 ++++++++++++++++++++--------------------
convert.c | 3 ++-
git-compat-util.h | 23 ++++++++++++++++++-----
http-push.c | 2 +-
pager.c | 3 ++-
pseudo-merge.c | 32 +++++++++++++++++++-------------
revision.c | 25 +++++++++++++++----------
run-command.c | 4 ++--
transport-helper.c | 3 ++-
10 files changed, 85 insertions(+), 57 deletions(-)
-Peff
next reply other threads:[~2026-03-31 23:38 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-31 23:38 Jeff King [this message]
2026-03-31 23:41 ` [PATCH 01/12] convert: add const to fix strchr() warnings Jeff King
2026-03-31 23:41 ` [PATCH 02/12] http: " Jeff King
2026-03-31 23:41 ` [PATCH 03/12] transport-helper: drop " Jeff King
2026-04-01 13:46 ` Patrick Steinhardt
2026-03-31 23:42 ` [PATCH 04/12] pager: explicitly cast away strchr() constness Jeff King
2026-04-01 20:50 ` Junio C Hamano
2026-04-02 3:54 ` Jeff King
2026-03-31 23:42 ` [PATCH 05/12] run-command: explicitly cast away constness when assigning to void Jeff King
2026-03-31 23:44 ` [PATCH 06/12] find_last_dir_sep(): convert inline function to macro Jeff King
2026-03-31 23:46 ` [PATCH 07/12] pseudo-merge: fix disk reads from find_pseudo_merge() Jeff King
2026-03-31 23:56 ` Jeff King
2026-04-01 21:40 ` Junio C Hamano
2026-04-02 23:51 ` Taylor Blau
2026-03-31 23:50 ` [PATCH 08/12] skip_prefix(): check const match between in and out params Jeff King
2026-04-01 13:17 ` Phillip Wood
2026-04-01 14:04 ` Phillip Wood
2026-04-01 19:24 ` Jeff King
2026-04-01 22:13 ` Junio C Hamano
2026-04-02 15:05 ` Phillip Wood
2026-04-01 13:46 ` Patrick Steinhardt
2026-03-31 23:51 ` [PATCH 09/12] pkt-line: make packet_reader.line non-const Jeff King
2026-04-01 22:18 ` Junio C Hamano
2026-04-02 3:55 ` Jeff King
2026-03-31 23:52 ` [PATCH 10/12] range-diff: drop const to fix strstr() warnings Jeff King
2026-03-31 23:52 ` [PATCH 11/12] http: drop const to fix strstr() warning Jeff King
2026-03-31 23:53 ` [PATCH 12/12] refs/files-backend: drop const to fix strchr() warning Jeff King
2026-04-01 13:46 ` Patrick Steinhardt
2026-04-01 22:22 ` Junio C Hamano
2026-04-02 3:56 ` Jeff King
2026-04-02 4:14 ` [PATCH v2 0/12] fixing the remainder of the C23 strchr warnings Jeff King
2026-04-02 4:14 ` [PATCH v2 01/12] convert: add const to fix strchr() warnings Jeff King
2026-04-02 4:14 ` [PATCH v2 02/12] http: " Jeff King
2026-04-02 4:14 ` [PATCH v2 03/12] transport-helper: drop " Jeff King
2026-04-02 4:14 ` [PATCH v2 04/12] pager: explicitly cast away strchr() constness Jeff King
2026-04-02 4:15 ` [PATCH v2 05/12] run-command: explicitly cast away constness when assigning to void Jeff King
2026-04-02 4:15 ` [PATCH v2 06/12] find_last_dir_sep(): convert inline function to macro Jeff King
2026-04-02 4:15 ` [PATCH v2 07/12] pseudo-merge: fix disk reads from find_pseudo_merge() Jeff King
2026-04-02 4:15 ` [PATCH v2 08/12] skip_prefix(): check const match between in and out params Jeff King
2026-04-02 5:11 ` Junio C Hamano
2026-04-02 6:01 ` Jeff King
2026-04-02 15:50 ` Junio C Hamano
2026-04-02 15:41 ` Junio C Hamano
2026-04-03 11:13 ` Toon Claes
2026-04-04 5:42 ` [PATCH v2 13/12] git-compat-util: fix CONST_OUTPARAM typo and indentation Jeff King
2026-04-02 4:15 ` [PATCH v2 09/12] pkt-line: make packet_reader.line non-const Jeff King
2026-04-02 4:15 ` [PATCH v2 10/12] range-diff: drop const to fix strstr() warnings Jeff King
2026-04-02 4:15 ` [PATCH v2 11/12] http: drop const to fix strstr() warning Jeff King
2026-04-02 4:15 ` [PATCH v2 12/12] refs/files-backend: drop const to fix strchr() warning Jeff King
2026-04-03 11:14 ` [PATCH v2 0/12] fixing the remainder of the C23 strchr warnings Toon Claes
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=20260331233856.GA2327197@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=collin.funk1@gmail.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