git: b169b80d409c - stable/15 - libc: Parenthesise qualifier-preserving function definitions

From: Faraz Vahedi <kfv_at_FreeBSD.org>
Date: Tue, 22 Sep 2026 19:01:36 UTC
The branch stable/15 has been updated by kfv:

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

commit b169b80d409c0aa5a3850172ca914a889f08d32a
Author:     Faraz Vahedi <kfv@FreeBSD.org>
AuthorDate: 2026-09-13 12:14:26 +0000
Commit:     Faraz Vahedi <kfv@FreeBSD.org>
CommitDate: 2026-09-22 17:27:10 +0000

    libc: Parenthesise qualifier-preserving function definitions
    
    Required to prevent function-like macros with the same name from
    being expanded in the definitions once they become active in a
    later C mode.  Without the parentheses, the macro would rewrite
    the declarator, and the file would consequently fail to compile.
    This style is already used for similar cases such as mempcpy().
    
    Reviewed by:    fuz
    Approved by:    fuz (mentor)
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D59600
    
    (cherry picked from commit c389738f21c09931cd88a84a357be514b5c60030)
---
 lib/libc/aarch64/string/strpbrk.c | 2 +-
 lib/libc/amd64/string/strpbrk.c   | 2 +-
 lib/libc/stdlib/bsearch.c         | 6 +++---
 lib/libc/string/memchr.c          | 2 +-
 lib/libc/string/memmem.c          | 2 +-
 lib/libc/string/memrchr.c         | 2 +-
 lib/libc/string/strcasestr.c      | 2 +-
 lib/libc/string/strchr.c          | 2 +-
 lib/libc/string/strnstr.c         | 2 +-
 lib/libc/string/strpbrk.c         | 2 +-
 lib/libc/string/strrchr.c         | 2 +-
 lib/libc/string/strstr.c          | 2 +-
 lib/libc/string/wcschr.c          | 2 +-
 lib/libc/string/wcspbrk.c         | 2 +-
 lib/libc/string/wcsrchr.c         | 2 +-
 lib/libc/string/wcsstr.c          | 2 +-
 lib/libc/string/wmemchr.c         | 2 +-
 sys/libkern/strchrnul.c           | 2 +-
 18 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/lib/libc/aarch64/string/strpbrk.c b/lib/libc/aarch64/string/strpbrk.c
index 87f587789991..bc908e4fff3a 100644
--- a/lib/libc/aarch64/string/strpbrk.c
+++ b/lib/libc/aarch64/string/strpbrk.c
@@ -33,7 +33,7 @@
 size_t __strcspn(const char *, const char *);
 
 char *
-strpbrk(const char *s, const char *charset)
+(strpbrk)(const char *s, const char *charset)
 {
 	size_t loc;
 
diff --git a/lib/libc/amd64/string/strpbrk.c b/lib/libc/amd64/string/strpbrk.c
index 87f587789991..bc908e4fff3a 100644
--- a/lib/libc/amd64/string/strpbrk.c
+++ b/lib/libc/amd64/string/strpbrk.c
@@ -33,7 +33,7 @@
 size_t __strcspn(const char *, const char *);
 
 char *
-strpbrk(const char *s, const char *charset)
+(strpbrk)(const char *s, const char *charset)
 {
 	size_t loc;
 
diff --git a/lib/libc/stdlib/bsearch.c b/lib/libc/stdlib/bsearch.c
index 6bfd44d4df6d..7d3f2afea87b 100644
--- a/lib/libc/stdlib/bsearch.c
+++ b/lib/libc/stdlib/bsearch.c
@@ -66,15 +66,15 @@ typedef DECLARE_BLOCK(int, compar_block, const void *, const void *);
  */
 #ifdef I_AM_BSEARCH_B
 void *
-bsearch_b(const void *key, const void *base0, size_t nmemb, size_t size,
+(bsearch_b)(const void *key, const void *base0, size_t nmemb, size_t size,
     compar_block compar)
 #elif defined(I_AM_BSEARCH_S)
 void *
-bsearch_s(const void *key, const void *base0, rsize_t nmemb, rsize_t size,
+(bsearch_s)(const void *key, const void *base0, rsize_t nmemb, rsize_t size,
     int (*compar)(const void *, const void *, void *), void *context)
 #else
 void *
-bsearch(const void *key, const void *base0, size_t nmemb, size_t size,
+(bsearch)(const void *key, const void *base0, size_t nmemb, size_t size,
     int (*compar)(const void *, const void *))
 #endif
 {
diff --git a/lib/libc/string/memchr.c b/lib/libc/string/memchr.c
index 367eac5108c1..b8a6dc73d008 100644
--- a/lib/libc/string/memchr.c
+++ b/lib/libc/string/memchr.c
@@ -33,7 +33,7 @@
 #define HASZERO(x) (((x)-ONES) & ~(x)&HIGHS)
 
 void *
-memchr(const void *src, int c, size_t n)
+(memchr)(const void *src, int c, size_t n)
 {
 	const unsigned char *s = src;
 	c = (unsigned char)c;
diff --git a/lib/libc/string/memmem.c b/lib/libc/string/memmem.c
index 4a244b5964ce..53eb8a9f3783 100644
--- a/lib/libc/string/memmem.c
+++ b/lib/libc/string/memmem.c
@@ -181,7 +181,7 @@ twoway_memmem(const unsigned char *h, const unsigned char *z,
 }
 
 void *
-memmem(const void *h0, size_t k, const void *n0, size_t l)
+(memmem)(const void *h0, size_t k, const void *n0, size_t l)
 {
 	const unsigned char *h = h0, *n = n0;
 
diff --git a/lib/libc/string/memrchr.c b/lib/libc/string/memrchr.c
index bd27ebc620e5..8b4942a6c41e 100644
--- a/lib/libc/string/memrchr.c
+++ b/lib/libc/string/memrchr.c
@@ -23,7 +23,7 @@
  * Find the last occurrence of 'c' in the buffer 's' of size 'n'.
  */
 void *
-memrchr(const void *s, int c, size_t n)
+(memrchr)(const void *s, int c, size_t n)
 {
 	const unsigned char *cp;
 
diff --git a/lib/libc/string/strcasestr.c b/lib/libc/string/strcasestr.c
index c1be973f01f4..23b3c1e7e24c 100644
--- a/lib/libc/string/strcasestr.c
+++ b/lib/libc/string/strcasestr.c
@@ -65,7 +65,7 @@ strcasestr_l(const char *s, const char *find, locale_t locale)
 	return ((char *)s);
 }
 char *
-strcasestr(const char *s, const char *find)
+(strcasestr)(const char *s, const char *find)
 {
 	return strcasestr_l(s, find, __get_locale());
 }
diff --git a/lib/libc/string/strchr.c b/lib/libc/string/strchr.c
index 8f6f947e9983..e6b3628535e0 100644
--- a/lib/libc/string/strchr.c
+++ b/lib/libc/string/strchr.c
@@ -27,7 +27,7 @@
 char *__strchrnul(const char *, int);
 
 char *
-strchr(const char *s, int c)
+(strchr)(const char *s, int c)
 {
 	char *r = __strchrnul(s, c);
 	return *(unsigned char *)r == (unsigned char)c ? r : NULL;
diff --git a/lib/libc/string/strnstr.c b/lib/libc/string/strnstr.c
index 71e6b1d0f0a7..935e296a592f 100644
--- a/lib/libc/string/strnstr.c
+++ b/lib/libc/string/strnstr.c
@@ -40,7 +40,7 @@
  * first slen characters of s.
  */
 char *
-strnstr(const char *s, const char *find, size_t slen)
+(strnstr)(const char *s, const char *find, size_t slen)
 {
 	char c, sc;
 	size_t len;
diff --git a/lib/libc/string/strpbrk.c b/lib/libc/string/strpbrk.c
index c7dd6c2cff37..7495bd228154 100644
--- a/lib/libc/string/strpbrk.c
+++ b/lib/libc/string/strpbrk.c
@@ -35,7 +35,7 @@
  * Find the first occurrence in s1 of a character in s2 (excluding NUL).
  */
 char *
-strpbrk(const char *s1, const char *s2)
+(strpbrk)(const char *s1, const char *s2)
 {
 	const char *scanp;
 	int c, sc;
diff --git a/lib/libc/string/strrchr.c b/lib/libc/string/strrchr.c
index 10cb32011cbd..809a1b41c474 100644
--- a/lib/libc/string/strrchr.c
+++ b/lib/libc/string/strrchr.c
@@ -33,7 +33,7 @@
 #include <string.h>
 
 char *
-strrchr(const char *p, int ch)
+(strrchr)(const char *p, int ch)
 {
 	char *save;
 	char c;
diff --git a/lib/libc/string/strstr.c b/lib/libc/string/strstr.c
index 90f8bc701e0f..5381cd17c16d 100644
--- a/lib/libc/string/strstr.c
+++ b/lib/libc/string/strstr.c
@@ -192,7 +192,7 @@ twoway_strstr(const unsigned char *h, const unsigned char *n)
 }
 
 char *
-strstr(const char *h, const char *n)
+(strstr)(const char *h, const char *n)
 {
 	/* Return immediately on empty needle */
 	if (!n[0])
diff --git a/lib/libc/string/wcschr.c b/lib/libc/string/wcschr.c
index 356f8025c317..ea36a17cddff 100644
--- a/lib/libc/string/wcschr.c
+++ b/lib/libc/string/wcschr.c
@@ -29,7 +29,7 @@
 #include <wchar.h>
 
 wchar_t *
-wcschr(const wchar_t *s, wchar_t c)
+(wcschr)(const wchar_t *s, wchar_t c)
 {
 
 	while (*s != c && *s != L'\0')
diff --git a/lib/libc/string/wcspbrk.c b/lib/libc/string/wcspbrk.c
index 62ad9a8130a2..d20ef1dfb1b8 100644
--- a/lib/libc/string/wcspbrk.c
+++ b/lib/libc/string/wcspbrk.c
@@ -37,7 +37,7 @@ __RCSID("$NetBSD: wcspbrk.c,v 1.1 2000/12/23 23:14:37 itojun Exp $");
 #include <wchar.h>
 
 wchar_t *
-wcspbrk(const wchar_t *s, const wchar_t *set)
+(wcspbrk)(const wchar_t *s, const wchar_t *set)
 {
 	const wchar_t *p;
 	const wchar_t *q;
diff --git a/lib/libc/string/wcsrchr.c b/lib/libc/string/wcsrchr.c
index 1679d808be2b..86cbbcafcae5 100644
--- a/lib/libc/string/wcsrchr.c
+++ b/lib/libc/string/wcsrchr.c
@@ -29,7 +29,7 @@
 #include <wchar.h>
 
 wchar_t *
-wcsrchr(const wchar_t *s, wchar_t c)
+(wcsrchr)(const wchar_t *s, wchar_t c)
 {
 	const wchar_t *last;
 
diff --git a/lib/libc/string/wcsstr.c b/lib/libc/string/wcsstr.c
index beb5e8931742..9579d8e32778 100644
--- a/lib/libc/string/wcsstr.c
+++ b/lib/libc/string/wcsstr.c
@@ -38,7 +38,7 @@
  * Find the first occurrence of find in s.
  */
 wchar_t *
-wcsstr(const wchar_t * __restrict s, const wchar_t * __restrict find)
+(wcsstr)(const wchar_t * __restrict s, const wchar_t * __restrict find)
 {
 	wchar_t c, sc;
 	size_t len;
diff --git a/lib/libc/string/wmemchr.c b/lib/libc/string/wmemchr.c
index 8724187ffd63..618c78c7fc2f 100644
--- a/lib/libc/string/wmemchr.c
+++ b/lib/libc/string/wmemchr.c
@@ -37,7 +37,7 @@ __RCSID("$NetBSD: wmemchr.c,v 1.1 2000/12/23 23:14:37 itojun Exp $");
 #include <wchar.h>
 
 wchar_t	*
-wmemchr(const wchar_t *s, wchar_t c, size_t n)
+(wmemchr)(const wchar_t *s, wchar_t c, size_t n)
 {
 	size_t i;
 
diff --git a/sys/libkern/strchrnul.c b/sys/libkern/strchrnul.c
index 2e8becff89b8..64ae0e60a41b 100644
--- a/sys/libkern/strchrnul.c
+++ b/sys/libkern/strchrnul.c
@@ -29,7 +29,7 @@
 #include <sys/libkern.h>
 
 char *
-strchrnul(const char *p, int ch)
+(strchrnul)(const char *p, int ch)
 {
 
 	for (; *p != 0 && *p != ch; p++)