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 --- nscd/pwdcache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'nscd/pwdcache.c') diff --git a/nscd/pwdcache.c b/nscd/pwdcache.c index f546bb3..e1b579d 100644 --- a/nscd/pwdcache.c +++ b/nscd/pwdcache.c @@ -243,7 +243,7 @@ cache_addpw (struct database_dyn *db, int fd, request_header *req, /* Finally the stringified UID value. */ memcpy (cp, buf, n); char *key_copy = cp + key_offset; - assert (key_copy == (char *) rawmemchr (cp, '\0') + 1); + assert (key_copy == strchr (cp, '\0') + 1); assert (cp == dataset->strdata + total - offsetof (struct dataset, strdata)); -- cgit v1.1