about summary refs log tree commit diff
path: root/string/test-strcmp.c
diff options
context:
space:
mode:
authorNoah Goldstein <goldstein.w.n@gmail.com>2022-02-08 15:24:59 -0600
committerNoah Goldstein <goldstein.w.n@gmail.com>2022-02-11 04:06:27 -0600
commit02561bb48a26429a238cbd6afbe5998dabcc4546 (patch)
treec51116299da248e7a7f9dc5b4303bebb689dc77a /string/test-strcmp.c
parentfb55d9b945ca7c88e01298657908fb3c54d0302c (diff)
downloadglibc-02561bb48a26429a238cbd6afbe5998dabcc4546.tar.gz
glibc-02561bb48a26429a238cbd6afbe5998dabcc4546.tar.xz
glibc-02561bb48a26429a238cbd6afbe5998dabcc4546.zip
String: Ensure 'MIN_PAGE_SIZE' is multiple of 'getpagesize'
When 'TEST_LEN' was defined as (4096 * 3) the allocation size Would
not be a multiple of system page size if system page size > 4096.
Diffstat (limited to 'string/test-strcmp.c')
-rw-r--r--string/test-strcmp.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/string/test-strcmp.c b/string/test-strcmp.c
index eacbdc8857..0abce769d0 100644
--- a/string/test-strcmp.c
+++ b/string/test-strcmp.c
@@ -16,7 +16,7 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#define TEST_LEN (4096 * 3)
+#define TEST_LEN (getpagesize () * 3)
 #define MIN_PAGE_SIZE (TEST_LEN + 2 * getpagesize ())
 
 #define TEST_MAIN
@@ -393,7 +393,7 @@ int
 test_main (void)
 {
   size_t i, j;
-
+  const size_t test_len = MIN(TEST_LEN, 3 * 4096);
   test_init ();
   check();
   check2 ();
@@ -435,7 +435,7 @@ test_main (void)
 
   for (j = 0; j < 160; ++j)
     {
-      for (i = 0; i < TEST_LEN;)
+      for (i = 0; i < test_len;)
         {
           do_test (getpagesize () - j - 1, 0, i, 127, 0);
           do_test (getpagesize () - j - 1, 0, i, 127, 1);
@@ -461,17 +461,17 @@ test_main (void)
             {
               i += 7;
             }
-          else if (i + 161 < TEST_LEN)
+          else if (i + 161 < test_len)
             {
               i += 31;
               i *= 17;
               i /= 16;
-              if (i + 161 > TEST_LEN)
+              if (i + 161 > test_len)
                 {
-                  i = TEST_LEN - 160;
+                  i = test_len - 160;
                 }
             }
-          else if (i + 32 < TEST_LEN)
+          else if (i + 32 < test_len)
             {
               i += 7;
             }