Avoid double bounds check at the start of the loop
Checks
Context |
Check |
Description |
redhat-pt-bot/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
redhat-pt-bot/TryBot-32bit |
success
|
Build for i686
|
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_glibc_check--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_glibc_build--master-arm |
success
|
Testing passed
|
Commit Message
---
string/memmem.c | 4 ++--
string/strstr.c | 2 ++
2 files changed, 4 insertions(+), 2 deletions(-)
@@ -92,7 +92,7 @@ __memmem (const void *haystack, size_t hs_len,
shift1 = m1 - shift[hash2 (ne + m1)];
shift[hash2 (ne + m1)] = m1;
- for ( ; hs <= end; )
+ do
{
/* Skip past character pairs not in the needle. */
do
@@ -121,7 +121,7 @@ __memmem (const void *haystack, size_t hs_len,
/* Skip based on matching the hash of the needle end. */
hs += shift1;
- }
+ } while (hs <= end);
return NULL;
}
libc_hidden_def (__memmem)
@@ -121,6 +121,7 @@ STRSTR (const char *haystack, const char *needle)
shift1 = m1 - shift[hash2 (ne + m1)];
shift[hash2 (ne + m1)] = m1;
+ goto start;
while (1)
{
if (__glibc_unlikely (hs > end))
@@ -130,6 +131,7 @@ STRSTR (const char *haystack, const char *needle)
return NULL;
}
+start:
/* Skip past character pairs not in the needle. */
do
{