aboutsummaryrefslogtreecommitdiff
path: root/nscd/netgroupcache.c
diff options
context:
space:
mode:
authorWilco Dijkstra <wilco.dijkstra@arm.com>2023-02-03 12:01:33 +0000
committerWilco Dijkstra <wilco.dijkstra@arm.com>2023-02-06 16:16:19 +0000
commit32c7acd46401530fdbd4e98508c9baaa705f8b53 (patch)
tree000fcd17f9b6ddbc14af397f33963e72a3c9d4bb /nscd/netgroupcache.c
parentd2d3f3720ce627a4fe154d8dd14db716a32bcc6e (diff)
downloadglibc-32c7acd46401530fdbd4e98508c9baaa705f8b53.tar.xz
glibc-32c7acd46401530fdbd4e98508c9baaa705f8b53.zip
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>
Diffstat (limited to 'nscd/netgroupcache.c')
-rw-r--r--nscd/netgroupcache.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/nscd/netgroupcache.c b/nscd/netgroupcache.c
index 439dd4ba38..06b7d7b6ca 100644
--- a/nscd/netgroupcache.c
+++ b/nscd/netgroupcache.c
@@ -453,14 +453,14 @@ addinnetgrX (struct database_dyn *db, int fd, request_header *req,
struct datahead *dh)
{
const char *group = key;
- key = (char *) rawmemchr (key, '\0') + 1;
+ key = strchr (key, '\0') + 1;
size_t group_len = key - group;
const char *host = *key++ ? key : NULL;
if (host != NULL)
- key = (char *) rawmemchr (key, '\0') + 1;
+ key = strchr (key, '\0') + 1;
const char *user = *key++ ? key : NULL;
if (user != NULL)
- key = (char *) rawmemchr (key, '\0') + 1;
+ key = strchr (key, '\0') + 1;
const char *domain = *key++ ? key : NULL;
if (__glibc_unlikely (debug_level > 0))
@@ -538,11 +538,11 @@ addinnetgrX (struct database_dyn *db, int fd, request_header *req,
match anything is stored in the netgroup cache. */
if (host != NULL && *triplets != '\0')
success = strcmp (host, triplets) == 0;
- triplets = (const char *) rawmemchr (triplets, '\0') + 1;
+ triplets = strchr (triplets, '\0') + 1;
if (success && user != NULL && *triplets != '\0')
success = strcmp (user, triplets) == 0;
- triplets = (const char *) rawmemchr (triplets, '\0') + 1;
+ triplets = strchr (triplets, '\0') + 1;
if (success && (domain == NULL || *triplets == '\0'
|| strcmp (domain, triplets) == 0))
@@ -550,7 +550,7 @@ addinnetgrX (struct database_dyn *db, int fd, request_header *req,
dataset->resp.result = 1;
break;
}
- triplets = (const char *) rawmemchr (triplets, '\0') + 1;
+ triplets = strchr (triplets, '\0') + 1;
}
}