From 32c7acd46401530fdbd4e98508c9baaa705f8b53 Mon Sep 17 00:00:00 2001 From: Wilco Dijkstra <wilco.dijkstra@arm.com> 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 <adhemerval.zanella@linaro.org> --- inet/getnetgrent_r.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'inet') diff --git a/inet/getnetgrent_r.c b/inet/getnetgrent_r.c index 833fe21..60f476b 100644 --- a/inet/getnetgrent_r.c +++ b/inet/getnetgrent_r.c @@ -217,11 +217,11 @@ nscd_getnetgrent (struct __netgrent *datap, char *buffer, size_t buflen, datap->type = triple_val; datap->val.triple.host = get_nonempty_val (datap->cursor); - datap->cursor = (char *) __rawmemchr (datap->cursor, '\0') + 1; + datap->cursor = strchr (datap->cursor, '\0') + 1; datap->val.triple.user = get_nonempty_val (datap->cursor); - datap->cursor = (char *) __rawmemchr (datap->cursor, '\0') + 1; + datap->cursor = strchr (datap->cursor, '\0') + 1; datap->val.triple.domain = get_nonempty_val (datap->cursor); - datap->cursor = (char *) __rawmemchr (datap->cursor, '\0') + 1; + datap->cursor = strchr (datap->cursor, '\0') + 1; return NSS_STATUS_SUCCESS; } -- cgit v1.1