This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix strncmp page test to limit length to size of object


Let's fix the test instead.

Andreas.

2011-03-29  Andreas Schwab  <schwab@redhat.com>

	* string/test-strncmp.c (do_page_test): Limit length to size of
	object.
---
 string/test-strncmp.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/string/test-strncmp.c b/string/test-strncmp.c
index 00971df..880b2be 100644
--- a/string/test-strncmp.c
+++ b/string/test-strncmp.c
@@ -204,6 +204,7 @@ do_page_test (size_t offset1, size_t offset2, char *s2)
 {
   char *s1;
   int exp_result;
+  size_t max_offset = offset1 > offset2 ? offset1 : offset2;
 
   if (offset1 >= page_size || offset2 >= page_size)
     return;
@@ -211,12 +212,12 @@ do_page_test (size_t offset1, size_t offset2, char *s2)
   s1 = (char *) (buf1 + offset1);
   s2 += offset2;
 
-  exp_result= *s1;
+  exp_result = *s1;
 
   FOR_EACH_IMPL (impl, 0)
     {
-      check_result (impl, s1, s2, page_size, -exp_result);
-      check_result (impl, s2, s1, page_size, exp_result);
+      check_result (impl, s1, s2, page_size - max_offset, -exp_result);
+      check_result (impl, s2, s1, page_size - max_offset, exp_result);
     }
 }
 
-- 
1.7.4


-- 
Andreas Schwab, schwab@redhat.com
GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84  5EC7 45C6 250E 6F00 984E
"And now for something completely different."


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]