From 32c7acd46401530fdbd4e98508c9baaa705f8b53 Mon Sep 17 00:00:00 2001 From: Wilco Dijkstra Date: Fri, 3 Feb 2023 12:01:33 +0000 Subject: Replace rawmemchr (s, '\0') with strchr Almost all uses of rawmemchr find the end of a string. Since most targets use a generic implementation, replacing it with strchr is better since that is optimized by compilers into strlen (s) + s. Also fix the generic rawmemchr implementation to use a cast to unsigned char in the if statement. Reviewed-by: Adhemerval Zanella --- nss/nss_db/db-XXX.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nss') diff --git a/nss/nss_db/db-XXX.c b/nss/nss_db/db-XXX.c index a81bd7466b..0ce730db5a 100644 --- a/nss/nss_db/db-XXX.c +++ b/nss/nss_db/db-XXX.c @@ -269,7 +269,7 @@ CONCAT(_nss_db_get,ENTNAME_r) (struct STRUCTURE *result, char *buffer, + state.header->valstrlen); while (entidx < end) { - const char *next = rawmemchr (entidx, '\0') + 1; + const char *next = strchr (entidx, '\0') + 1; size_t len = next - entidx; if (len > buflen) -- cgit 1.4.1