git: 78f842dda35b - main - sort: Const correctness for C23

Lexi Winter <[email protected]> Mon, 03 Aug 2026 14:30:43 +0000
Newsgroups gmane.os.freebsd.devel.cvs.src
Message-ID <6a70a613.37031.76e4a9da__9518.36593901447$1785767486$gmane$org@gitrepo.freebsd.org>
The branch main has been updated by ivy:

URL: https://cgit.FreeBSD.org/src/commit/?id=78f842dda35b7280e8682f90506ff05b591c6b3a

commit 78f842dda35b7280e8682f90506ff05b591c6b3a
Author:     Lexi Winter <[email protected]>
AuthorDate: 2026-08-03 14:06:18 +0000
Commit:     Lexi Winter <[email protected]>
CommitDate: 2026-08-03 14:06:18 +0000

    sort: Const correctness for C23
    
    On some platforms, e.g. Linux Clang 22.1.8 / glibc 2.43, strchr()
    now implements the C23 behaviour where passing a const pointer to
    strchr() also returns a const pointer.  This breaks sort during
    the bootstrap build, since it assumes the return value is always
    a mutable pointer.
    
    As the returned pointer is never used to modify the value, fix this
    by making the temporary variable const.
    
    MFC after:      1 week
    Reviewed by:    markj
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D58491
---
 usr.bin/sort/sort.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/usr.bin/sort/sort.c b/usr.bin/sort/sort.c
index 6e4023c43063..422884573ae9 100644
--- a/usr.bin/sort/sort.c
+++ b/usr.bin/sort/sort.c
@@ -735,7 +735,7 @@ parse_k(const char *s, struct key_specs *ks)
 	    { false, false, false, false, false, false };
 
 	if (s && *s) {
-		char *sptr;
+		const char *sptr;
 
 		sptr = strchr(s, ',');
 		if (sptr) {