git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 0/12] fixing the remainder of the C23 strchr warnings

From
Jeff King <peff@peff.net>
Date
Mar 31, 2026, 23:38 UTC
Message-ID
<20260331233856.GA2327197@coredump.intra.peff.net>

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: Jeff King
Message 1 of 50 in “fixing the remainder of the C23 strchr warnings”
  1. 0/12 fixing the remainder of the C23 strchr warningsJeff King, Mar 31, 2026
  2. 01/12 convert: add const to fix strchr() warningsJeff King, Mar 31, 2026
  3. 02/12 http: add const to fix strchr() warningsJeff King, Mar 31, 2026
  4. 03/12 transport-helper: drop const to fix strchr() warningsJeff King, Mar 31, 2026
  5. Patrick SteinhardtApr 1, 2026
  6. 04/12 pager: explicitly cast away strchr() constnessJeff King, Mar 31, 2026
  7. Junio C HamanoApr 1, 2026
  8. Jeff KingApr 2, 2026
  9. 05/12 run-command: explicitly cast away constness when assigning to voidJeff King, Mar 31, 2026
  10. 06/12 find_last_dir_sep(): convert inline function to macroJeff King, Mar 31, 2026
  11. 07/12 pseudo-merge: fix disk reads from find_pseudo_merge()Jeff King, Mar 31, 2026
  12. Jeff KingMar 31, 2026
  13. Junio C HamanoApr 1, 2026
  14. Taylor BlauApr 2, 2026
  15. 08/12 skip_prefix(): check const match between in and out paramsJeff King, Mar 31, 2026
  16. Phillip WoodApr 1, 2026
  17. Phillip WoodApr 1, 2026
  18. Jeff KingApr 1, 2026
  19. Junio C HamanoApr 1, 2026
  20. Phillip WoodApr 2, 2026
  21. Patrick SteinhardtApr 1, 2026
  22. 09/12 pkt-line: make packet_reader.line non-constJeff King, Mar 31, 2026
  23. Junio C HamanoApr 1, 2026
  24. Jeff KingApr 2, 2026
  25. 10/12 range-diff: drop const to fix strstr() warningsJeff King, Mar 31, 2026
  26. 11/12 http: drop const to fix strstr() warningJeff King, Mar 31, 2026
  27. 12/12 refs/files-backend: drop const to fix strchr() warningJeff King, Mar 31, 2026
  28. Patrick SteinhardtApr 1, 2026
  29. Junio C HamanoApr 1, 2026
  30. Jeff KingApr 2, 2026
  31. 0/12 fixing the remainder of the C23 strchr warningsJeff King, Apr 2, 2026
  32. 01/12 convert: add const to fix strchr() warningsJeff King, Apr 2, 2026
  33. 02/12 http: add const to fix strchr() warningsJeff King, Apr 2, 2026
  34. 03/12 transport-helper: drop const to fix strchr() warningsJeff King, Apr 2, 2026
  35. 04/12 pager: explicitly cast away strchr() constnessJeff King, Apr 2, 2026
  36. 05/12 run-command: explicitly cast away constness when assigning to voidJeff King, Apr 2, 2026
  37. 06/12 find_last_dir_sep(): convert inline function to macroJeff King, Apr 2, 2026
  38. 07/12 pseudo-merge: fix disk reads from find_pseudo_merge()Jeff King, Apr 2, 2026
  39. 08/12 skip_prefix(): check const match between in and out paramsJeff King, Apr 2, 2026
  40. Junio C HamanoApr 2, 2026
  41. Jeff KingApr 2, 2026
  42. Junio C HamanoApr 2, 2026
  43. Junio C HamanoApr 2, 2026
  44. Toon ClaesApr 3, 2026
  45. 13/12 git-compat-util: fix CONST_OUTPARAM typo and indentationJeff King, Apr 4, 2026
  46. 09/12 pkt-line: make packet_reader.line non-constJeff King, Apr 2, 2026
  47. 10/12 range-diff: drop const to fix strstr() warningsJeff King, Apr 2, 2026
  48. 11/12 http: drop const to fix strstr() warningJeff King, Apr 2, 2026
  49. 12/12 refs/files-backend: drop const to fix strchr() warningJeff King, Apr 2, 2026
  50. Toon ClaesApr 3, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.