[rtems commit] libtests/malloctest: Fix 64-bit targets

Sebastian Huber sebh at rtems.org
Fri Nov 24 14:27:18 UTC 2017


Module:    rtems
Branch:    master
Commit:    57f96b999dbdef888c1af8e712b3ea726bf03047
Changeset: http://git.rtems.org/rtems/commit/?id=57f96b999dbdef888c1af8e712b3ea726bf03047

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Nov 24 15:26:38 2017 +0100

libtests/malloctest: Fix 64-bit targets

Update #3082.

---

 testsuites/libtests/malloctest/init.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/testsuites/libtests/malloctest/init.c b/testsuites/libtests/malloctest/init.c
index 6be6c1c..577f557 100644
--- a/testsuites/libtests/malloctest/init.c
+++ b/testsuites/libtests/malloctest/init.c
@@ -1173,7 +1173,7 @@ static void test_heap_size_with_overhead(void)
 static void test_posix_memalign(void)
 {
   void *p1;
-  int i;
+  size_t i;
   int sc;
   int maximumShift;
 
@@ -1199,14 +1199,16 @@ static void test_posix_memalign(void)
 
   maximumShift = (sizeof(size_t) * CHAR_BIT) - 1;
   for ( i=sizeof(void *) ; i<maximumShift ; i++ ) {
-    size_t alignment = 1 << i;
+    size_t alignment = 1;
+
+    alignment <<= i;
 
     p1 = NULL; /* Initialize p1 to aovid used uninitialized */
 
-    printf( "posix_memalign - alignment of %zd -- OK\n", alignment);
+    printf( "posix_memalign - alignment of %zu -- OK\n", alignment);
     sc = posix_memalign( &p1, alignment, 8 );
     if ( sc == ENOMEM ) {
-      printf( "posix_memalign - ran out of memory trying %zd\n", alignment );
+      printf( "posix_memalign - ran out of memory trying %zu\n", alignment );
       break;
     }
     posix_service_failed( sc, "posix_memalign alignment OK" );



More information about the vc mailing list