git: 73d3c964be93 - main - libc: Preserve const qualifier on strchr(3), strrchr(3), and memchr(3) results
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 13 Sep 2026 12:33:19 UTC
The branch main has been updated by kfv:
URL: https://cgit.FreeBSD.org/src/commit/?id=73d3c964be93034daf26a55ebac38c2152769f74
commit 73d3c964be93034daf26a55ebac38c2152769f74
Author: Faraz Vahedi <kfv@FreeBSD.org>
AuthorDate: 2026-09-13 12:27:45 +0000
Commit: Faraz Vahedi <kfv@FreeBSD.org>
CommitDate: 2026-09-13 12:33:00 +0000
libc: Preserve const qualifier on strchr(3), strrchr(3), and memchr(3) results
Reviewed by: dteske, fuz
Approved by: dteske (mentor), fuz (mentor)
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D59612
---
lib/libc/gen/getgrent.c | 4 ++--
lib/libc/gen/syslog.c | 3 ++-
lib/libc/iconv/bsd_iconv.c | 3 +--
lib/libc/iconv/citrus_prop.c | 2 +-
lib/libc/inet/inet_cidr_pton.c | 3 ++-
lib/libc/nameser/ns_name.c | 2 +-
lib/libc/net/base64.c | 2 +-
lib/libc/net/getaddrinfo.c | 7 ++++---
lib/libc/net/rcmdsh.c | 2 +-
lib/libc/stdio/mktemp.c | 2 +-
10 files changed, 16 insertions(+), 14 deletions(-)
diff --git a/lib/libc/gen/getgrent.c b/lib/libc/gen/getgrent.c
index 8819708556b9..ee73c7eb6d39 100644
--- a/lib/libc/gen/getgrent.c
+++ b/lib/libc/gen/getgrent.c
@@ -1313,10 +1313,10 @@ compat_group(void *retval, void *mdata, va_list ap)
};
struct compat_state *st;
enum nss_lookup_type how;
- const char *name, *line;
+ const char *name, *line, *p;
struct group *grp;
gid_t gid;
- char *buffer, *p;
+ char *buffer;
void *discard;
size_t bufsize, linesize;
off_t pos;
diff --git a/lib/libc/gen/syslog.c b/lib/libc/gen/syslog.c
index a6290ee81a29..98b5056c65d5 100644
--- a/lib/libc/gen/syslog.c
+++ b/lib/libc/gen/syslog.c
@@ -467,7 +467,8 @@ setlogmask(int pmask)
static void
parse_tag(void)
{
- char *begin, *end, *p;
+ const char *begin, *end;
+ char *p;
pid_t pid;
if (LogTag == NULL || (LogStat & LOG_PID) != 0)
diff --git a/lib/libc/iconv/bsd_iconv.c b/lib/libc/iconv/bsd_iconv.c
index d3da6fd1a271..fb92b8f48ad0 100644
--- a/lib/libc/iconv/bsd_iconv.c
+++ b/lib/libc/iconv/bsd_iconv.c
@@ -250,8 +250,7 @@ __bsd_iconvctl(iconv_t cd, int request, void *argument)
{
struct _citrus_iconv *cv;
struct iconv_hooks *hooks;
- const char *convname;
- char *dst;
+ const char *convname, *dst;
int *i;
size_t srclen;
diff --git a/lib/libc/iconv/citrus_prop.c b/lib/libc/iconv/citrus_prop.c
index 6dadce92e3eb..5f01f1f29df4 100644
--- a/lib/libc/iconv/citrus_prop.c
+++ b/lib/libc/iconv/citrus_prop.c
@@ -81,7 +81,7 @@ _citrus_prop_read_##_func_##_common(struct _memstream * __restrict ms, \
{ \
_type_ acc, cutoff; \
int ch, cutlim, n; \
- char *p; \
+ const char *p; \
\
acc = (_type_)0; \
cutoff = _max_ / base; \
diff --git a/lib/libc/inet/inet_cidr_pton.c b/lib/libc/inet/inet_cidr_pton.c
index e24efcedc935..1d07e5c9e677 100644
--- a/lib/libc/inet/inet_cidr_pton.c
+++ b/lib/libc/inet/inet_cidr_pton.c
@@ -251,7 +251,8 @@ inet_cidr_pton_ipv6(const char *src, u_char *dst, int *pbits) {
static int
getbits(const char *src, int ipv6) {
int bits = 0;
- char *cp, ch;
+ const char *cp;
+ char ch;
if (*src == '\0') /*%< syntax */
return (-2);
diff --git a/lib/libc/nameser/ns_name.c b/lib/libc/nameser/ns_name.c
index ab6a81ed7b4e..35dc5fbd4fd5 100644
--- a/lib/libc/nameser/ns_name.c
+++ b/lib/libc/nameser/ns_name.c
@@ -216,7 +216,7 @@ int
ns_name_pton2(const char *src, u_char *dst, size_t dstsiz, size_t *dstlen) {
u_char *label, *bp, *eom;
int c, n, escaped, e = 0;
- char *cp;
+ const char *cp;
escaped = 0;
bp = dst;
diff --git a/lib/libc/net/base64.c b/lib/libc/net/base64.c
index f508275e4eb9..a0712f575e76 100644
--- a/lib/libc/net/base64.c
+++ b/lib/libc/net/base64.c
@@ -193,7 +193,7 @@ b64_pton(const char *src, u_char *target, size_t targsize)
{
int tarindex, state, ch;
u_char nextbyte;
- char *pos;
+ const char *pos;
state = 0;
tarindex = 0;
diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c
index b8af23ebe8da..64e7f30ff412 100644
--- a/lib/libc/net/getaddrinfo.c
+++ b/lib/libc/net/getaddrinfo.c
@@ -272,7 +272,7 @@ static int is_ifdisabled(char *);
static void set_source(struct ai_order *, struct policyhead *);
static int comp_dst(const void *, const void *);
#ifdef INET6
-static int ip6_str2scopeid(char *, struct sockaddr_in6 *, u_int32_t *);
+static int ip6_str2scopeid(const char *, struct sockaddr_in6 *, u_int32_t *);
#endif
static int gai_addr2scopetype(struct sockaddr *);
@@ -1338,7 +1338,8 @@ explore_numeric_scope(const struct addrinfo *pai, const char *hostname,
const struct afd *afd;
struct addrinfo *cur;
int error;
- char *cp, *hostname2 = NULL, *scope, *addr;
+ char *hostname2 = NULL, *addr;
+ const char *cp, *scope;
struct sockaddr_in6 *sin6;
afd = find_afd(pai->ai_family);
@@ -1682,7 +1683,7 @@ is_ifdisabled(char *name)
/* convert a string to a scope identifier. XXX: IPv6 specific */
static int
-ip6_str2scopeid(char *scope, struct sockaddr_in6 *sin6, u_int32_t *scopeid)
+ip6_str2scopeid(const char *scope, struct sockaddr_in6 *sin6, u_int32_t *scopeid)
{
u_long lscopeid;
struct in6_addr *a6;
diff --git a/lib/libc/net/rcmdsh.c b/lib/libc/net/rcmdsh.c
index 7e400e99cb3b..509490cfe459 100644
--- a/lib/libc/net/rcmdsh.c
+++ b/lib/libc/net/rcmdsh.c
@@ -62,7 +62,7 @@ rcmdsh(char **ahost, int rport, const char *locuser, const char *remuser,
struct addrinfo hints, *res;
int sp[2], error;
pid_t cpid;
- char *p;
+ const char *p;
struct passwd *pw;
char num[8];
static char hbuf[NI_MAXHOST];
diff --git a/lib/libc/stdio/mktemp.c b/lib/libc/stdio/mktemp.c
index a2f80ee7b0dd..827d686bdaa8 100644
--- a/lib/libc/stdio/mktemp.c
+++ b/lib/libc/stdio/mktemp.c
@@ -113,7 +113,7 @@ static int
_gettemp(int dfd, char *path, int *doopen, int domkdir, int slen, int oflags)
{
char *start, *trv, *suffp, *carryp;
- char *pad;
+ const char *pad;
struct stat sbuf;
uint32_t rand;
char carrybuf[MAXPATHLEN];