diff options
author | Wilco Dijkstra <wilco.dijkstra@arm.com> | 2023-02-03 12:01:33 +0000 |
---|---|---|
committer | Wilco Dijkstra <wilco.dijkstra@arm.com> | 2023-02-06 16:16:19 +0000 |
commit | 32c7acd46401530fdbd4e98508c9baaa705f8b53 (patch) | |
tree | 000fcd17f9b6ddbc14af397f33963e72a3c9d4bb /elf | |
parent | d2d3f3720ce627a4fe154d8dd14db716a32bcc6e (diff) | |
download | glibc-32c7acd46401530fdbd4e98508c9baaa705f8b53.tar.gz glibc-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 'elf')
-rw-r--r-- | elf/dl-support.c | 2 | ||||
-rw-r--r-- | elf/ldconfig.c | 2 | ||||
-rw-r--r-- | elf/rtld.c | 5 |
3 files changed, 4 insertions, 5 deletions
diff --git a/elf/dl-support.c b/elf/dl-support.c index 9714f75db0..d2519ce1a9 100644 --- a/elf/dl-support.c +++ b/elf/dl-support.c @@ -326,7 +326,7 @@ _dl_non_dynamic_init (void) while (cp < unsecure_envvars + sizeof (unsecure_envvars)) { __unsetenv (cp); - cp = (const char *) __rawmemchr (cp, '\0') + 1; + cp = strchr (cp, '\0') + 1; } #if !HAVE_TUNABLES diff --git a/elf/ldconfig.c b/elf/ldconfig.c index 166dccb528..3f1b30c570 100644 --- a/elf/ldconfig.c +++ b/elf/ldconfig.c @@ -1201,7 +1201,7 @@ main (int argc, char **argv) if (opt_chroot != NULL) { /* Normalize the path a bit, we might need it for printing later. */ - char *endp = rawmemchr (opt_chroot, '\0'); + char *endp = strchr (opt_chroot, '\0'); while (endp > opt_chroot && endp[-1] == '/') --endp; *endp = '\0'; diff --git a/elf/rtld.c b/elf/rtld.c index b8467f37cf..f82fbeb132 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -1024,7 +1024,7 @@ ERROR: audit interface '%s' requires version %d (maximum supported version %d); newp->fptr[cnt] = NULL; ++cnt; - cp = rawmemchr (cp, '\0') + 1; + cp = strchr (cp, '\0') + 1; } while (*cp != '\0'); assert (cnt == naudit_ifaces); @@ -2690,8 +2690,7 @@ process_envvars (struct dl_main_state *state) do { unsetenv (nextp); - /* We could use rawmemchr but this need not be fast. */ - nextp = (char *) (strchr) (nextp, '\0') + 1; + nextp = strchr (nextp, '\0') + 1; } while (*nextp != '\0'); |