git: 8c71eb51d2ee - stable/15 - libucl: Const correctness for C23

From: Lexi Winter <ivy_at_FreeBSD.org>
Date: Wed, 26 Aug 2026 10:12:35 UTC
The branch stable/15 has been updated by ivy:

URL: https://cgit.FreeBSD.org/src/commit/?id=8c71eb51d2eec6f2a29eaa171b3f6ca51d8c76c6

commit 8c71eb51d2eec6f2a29eaa171b3f6ca51d8c76c6
Author:     Lexi Winter <ivy@FreeBSD.org>
AuthorDate: 2026-08-03 14:05:09 +0000
Commit:     Lexi Winter <ivy@FreeBSD.org>
CommitDate: 2026-08-26 09:56:12 +0000

    libucl: 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 libucl during
    the bootstrap build, since it assumes the return value is always
    a mutable pointer.
    
    Instead of assigning directly to params->prefix (which is const),
    use a non-const temporary variable and assign the result after
    we've done the modification.
    
    MFC after:      1 week
    Reviewed by:    bofh, bapt
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D58490
    
    (cherry picked from commit bcee560d390eb8aa8fd0f08a7a0bffb6e77fffc6)
---
 contrib/libucl/src/ucl_util.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/contrib/libucl/src/ucl_util.c b/contrib/libucl/src/ucl_util.c
index 8f97c20db503..b9f689a3dd67 100644
--- a/contrib/libucl/src/ucl_util.c
+++ b/contrib/libucl/src/ucl_util.c
@@ -1090,7 +1090,7 @@ ucl_include_file_single (const unsigned char *data, size_t len,
 	bool res;
 	struct ucl_chunk *chunk;
 	unsigned char *buf = NULL;
-	char *old_curfile, *ext;
+	char *old_curfile, *ext, *tmp;
 	size_t buflen = 0;
 	char filebuf[PATH_MAX], realbuf[PATH_MAX];
 	int prev_state;
@@ -1201,12 +1201,13 @@ ucl_include_file_single (const unsigned char *data, size_t len,
 
 	if (params->use_prefix && params->prefix == NULL) {
 		/* Auto generate a key name based on the included filename */
-		params->prefix = basename (realbuf);
-		ext = strrchr (params->prefix, '.');
+		tmp = basename(realbuf);
+		ext = strrchr(tmp, '.');
 		if (ext != NULL && (strcmp (ext, ".conf") == 0 || strcmp (ext, ".ucl") == 0)) {
 			/* Strip off .conf or .ucl */
 			*ext = '\0';
 		}
+		params->prefix = tmp;
 	}
 	if (params->prefix != NULL) {
 		/* This is a prefixed include */