|
|
147e83 |
Fix type errors in string tests introduced by the patches to implement
|
|
|
147e83 |
rhbz#1268008.
|
|
|
147e83 |
|
|
|
147e83 |
Patch originally from Stefan Liebler <STLI@de.ibm.com>.
|
|
|
147e83 |
|
|
|
147e83 |
diff --git a/benchtests/bench-stpncpy.c b/benchtests/bench-stpncpy.c
|
|
|
147e83 |
index e428102f5db30cfc..d37b401e303fd4bc 100644
|
|
|
147e83 |
--- a/benchtests/bench-stpncpy.c
|
|
|
147e83 |
+++ b/benchtests/bench-stpncpy.c
|
|
|
147e83 |
@@ -74,4 +74,5 @@ STUPID_STPNCPY (CHAR *dst, const CHAR *src, size_t n)
|
|
|
147e83 |
return dst + nc;
|
|
|
147e83 |
}
|
|
|
147e83 |
|
|
|
147e83 |
+#undef CHAR
|
|
|
147e83 |
#include "bench-strncpy.c"
|
|
|
147e83 |
diff --git a/benchtests/bench-strncpy.c b/benchtests/bench-strncpy.c
|
|
|
147e83 |
index 2cfd56ab5ab2cb06..94f66f93acfd18fc 100644
|
|
|
147e83 |
--- a/benchtests/bench-strncpy.c
|
|
|
147e83 |
+++ b/benchtests/bench-strncpy.c
|
|
|
147e83 |
@@ -144,6 +144,8 @@ do_test (size_t align1, size_t align2, size_t len, size_t n, int max_char)
|
|
|
147e83 |
size_t i;
|
|
|
147e83 |
CHAR *s1, *s2;
|
|
|
147e83 |
|
|
|
147e83 |
+/* For wcsncpy: align1 and align2 here mean alignment not in bytes,
|
|
|
147e83 |
+ but in wchar_ts, in bytes it will equal to align * (sizeof (wchar_t)). */
|
|
|
147e83 |
align1 &= 7;
|
|
|
147e83 |
if ((align1 + len) * sizeof (CHAR) >= page_size)
|
|
|
147e83 |
return;
|
|
|
147e83 |
@@ -152,8 +154,8 @@ do_test (size_t align1, size_t align2, size_t len, size_t n, int max_char)
|
|
|
147e83 |
if ((align2 + len) * sizeof (CHAR) >= page_size)
|
|
|
147e83 |
return;
|
|
|
147e83 |
|
|
|
147e83 |
- s1 = (CHAR *) (buf1 + align1);
|
|
|
147e83 |
- s2 = (CHAR *) (buf2 + align2);
|
|
|
147e83 |
+ s1 = (CHAR *) (buf1) + align1;
|
|
|
147e83 |
+ s2 = (CHAR *) (buf2) + align2;
|
|
|
147e83 |
|
|
|
147e83 |
for (i = 0; i < len; ++i)
|
|
|
147e83 |
s1[i] = 32 + 23 * i % (max_char - 32);
|
|
|
147e83 |
diff --git a/benchtests/bench-strspn.c b/benchtests/bench-strspn.c
|
|
|
147e83 |
index e1f227278480ac7a..39039d09915e191e 100644
|
|
|
147e83 |
--- a/benchtests/bench-strspn.c
|
|
|
147e83 |
+++ b/benchtests/bench-strspn.c
|
|
|
147e83 |
@@ -139,7 +139,7 @@ do_test (size_t align, size_t pos, size_t len)
|
|
|
147e83 |
for (i = 0; i < pos; ++i)
|
|
|
147e83 |
s[i] = acc[random () % len];
|
|
|
147e83 |
s[pos] = random () & BIG_CHAR;
|
|
|
147e83 |
- if (strchr (acc, s[pos]))
|
|
|
147e83 |
+ if (STRCHR (acc, s[pos]))
|
|
|
147e83 |
s[pos] = '\0';
|
|
|
147e83 |
else
|
|
|
147e83 |
{
|
|
|
147e83 |
diff --git a/string/test-stpncpy.c b/string/test-stpncpy.c
|
|
|
147e83 |
index 69c8181269523def..f35340957f7092a9 100644
|
|
|
147e83 |
--- a/string/test-stpncpy.c
|
|
|
147e83 |
+++ b/string/test-stpncpy.c
|
|
|
147e83 |
@@ -75,4 +75,5 @@ STUPID_STPNCPY (CHAR *dst, const CHAR *src, size_t n)
|
|
|
147e83 |
return dst + nc;
|
|
|
147e83 |
}
|
|
|
147e83 |
|
|
|
147e83 |
+#undef CHAR
|
|
|
147e83 |
#include "test-strncpy.c"
|
|
|
147e83 |
diff --git a/string/test-strcat.c b/string/test-strcat.c
|
|
|
147e83 |
index a822733cff7fd39e..dca8dd47aa119ce0 100644
|
|
|
147e83 |
--- a/string/test-strcat.c
|
|
|
147e83 |
+++ b/string/test-strcat.c
|
|
|
147e83 |
@@ -71,7 +71,7 @@ SIMPLE_STRCAT (CHAR *dst, const CHAR *src)
|
|
|
147e83 |
}
|
|
|
147e83 |
|
|
|
147e83 |
static void
|
|
|
147e83 |
-do_one_test (impl_t *impl, CHAR *dst, const char *src)
|
|
|
147e83 |
+do_one_test (impl_t *impl, CHAR *dst, const CHAR *src)
|
|
|
147e83 |
{
|
|
|
147e83 |
size_t k = STRLEN (dst);
|
|
|
147e83 |
if (CALL (impl, dst, src) != dst)
|
|
|
147e83 |
diff --git a/string/test-strncmp.c b/string/test-strncmp.c
|
|
|
147e83 |
index 950bf248385787b6..63b16eaa385f942a 100644
|
|
|
147e83 |
--- a/string/test-strncmp.c
|
|
|
147e83 |
+++ b/string/test-strncmp.c
|
|
|
147e83 |
@@ -210,7 +210,7 @@ do_test (size_t align1, size_t align2, size_t len, size_t n, int max_char,
|
|
|
147e83 |
if (align1 + (n + 1) * CHARBYTES >= page_size)
|
|
|
147e83 |
return;
|
|
|
147e83 |
|
|
|
147e83 |
- align2 &= 7;
|
|
|
147e83 |
+ align2 &= 63;
|
|
|
147e83 |
if (align2 + (n + 1) * CHARBYTES >= page_size)
|
|
|
147e83 |
return;
|
|
|
147e83 |
|
|
|
147e83 |
@@ -359,8 +359,8 @@ check1 (void)
|
|
|
147e83 |
size_t i, offset;
|
|
|
147e83 |
int exp_result;
|
|
|
147e83 |
|
|
|
147e83 |
- strcpy(s1, L("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrs"));
|
|
|
147e83 |
- strcpy(s2, L("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkLMNOPQRSTUV"));
|
|
|
147e83 |
+ STRCPY(s1, L("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrs"));
|
|
|
147e83 |
+ STRCPY(s2, L("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkLMNOPQRSTUV"));
|
|
|
147e83 |
|
|
|
147e83 |
/* Check possible overflow bug for wcsncmp */
|
|
|
147e83 |
s1[4] = CHAR__MAX;
|
|
|
147e83 |
diff --git a/string/test-strncpy.c b/string/test-strncpy.c
|
|
|
147e83 |
index bdccc98301f22c10..1dbc57d9c33e6eb9 100644
|
|
|
147e83 |
--- a/string/test-strncpy.c
|
|
|
147e83 |
+++ b/string/test-strncpy.c
|
|
|
147e83 |
@@ -94,7 +94,7 @@ STUPID_STRNCPY (CHAR *dst, const CHAR *src, size_t n)
|
|
|
147e83 |
typedef CHAR *(*proto_t) (CHAR *, const CHAR *, size_t);
|
|
|
147e83 |
|
|
|
147e83 |
static void
|
|
|
147e83 |
-do_one_test (impl_t *impl, CHAR *dst, const char *src, size_t len, size_t n)
|
|
|
147e83 |
+do_one_test (impl_t *impl, CHAR *dst, const CHAR *src, size_t len, size_t n)
|
|
|
147e83 |
{
|
|
|
147e83 |
if (CALL (impl, dst, src, n) != STRNCPY_RESULT (dst, len, n))
|
|
|
147e83 |
{
|
|
|
147e83 |
diff --git a/string/test-strnlen.c b/string/test-strnlen.c
|
|
|
147e83 |
index 43db896e917ec4e0..db999b53fb546460 100644
|
|
|
147e83 |
--- a/string/test-strnlen.c
|
|
|
147e83 |
+++ b/string/test-strnlen.c
|
|
|
147e83 |
@@ -80,7 +80,7 @@ do_test (size_t align, size_t len, size_t maxlen, int max_char)
|
|
|
147e83 |
CHAR *buf = (CHAR *) (buf1);
|
|
|
147e83 |
|
|
|
147e83 |
for (i = 0; i < len; ++i)
|
|
|
147e83 |
- buf[align + i] = 1 + 7 * i % max_char;
|
|
|
147e83 |
+ buf[align + i] = 1 + 11111 * i % max_char;
|
|
|
147e83 |
buf[align + len] = 0;
|
|
|
147e83 |
|
|
|
147e83 |
FOR_EACH_IMPL (impl, 0)
|