[PATCH 5/5] testsuites/libtests/malloctest: fix warning

Matthew Joyce matthew.joyce at embedded-brains.de
Wed Jun 8 13:34:53 UTC 2022


From: Matt Joyce <matthew.joyce at embedded-brains.de>

Removed problematic free() and several unnecessary print statement
parameters. This fixes new warnings in gcc 12.
---
 testsuites/libtests/malloctest/init.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/testsuites/libtests/malloctest/init.c b/testsuites/libtests/malloctest/init.c
index 05d97a27d5..bf623f9cbe 100644
--- a/testsuites/libtests/malloctest/init.c
+++ b/testsuites/libtests/malloctest/init.c
@@ -60,8 +60,7 @@ static void test_realloc(void)
   for (i=2 ; i<2048 ; i++) {
     p2 = realloc(p1, i);
     if (p2 != p1)
-      printf( "realloc - failed grow in place: "
-              "%p != realloc(%p,%zu)\n", p1, p2, i);
+      printf( "realloc - failed grow in place");
     p1 = p2;
   }
   free(p1);
@@ -71,8 +70,7 @@ static void test_realloc(void)
   for (i=2047 ; i>=1; i--)  {
     p2 = realloc(p1, i);
     if (p2 != p1)
-      printf( "realloc - failed shrink in place: "
-              "%p != realloc(%p,%zu)\n", p1, p2, i);
+      printf( "realloc - failed shrink in place");
     p1 = p2;
   }
   free(p1);
@@ -85,7 +83,7 @@ static void test_realloc(void)
   p3 = realloc(p1, 64);
   if (p3 == p1 || p3 == NULL)
     printf(
-      "realloc - failed non-in place: realloc(%p,%d) = %p\n", p1, 64, p3);
+      "realloc - failed non-in place");
   free(p3);
   free(p2);
 
@@ -118,13 +116,6 @@ static void test_realloc(void)
   malloc_walk_ok = malloc_walk( 1234, false );
   rtems_test_assert( malloc_walk_ok );
   _Thread_Dispatch_enable( _Per_CPU_Get() );
-
-  /*
-   *  Realloc with a bad pointer to force a point
-   */
-  p4 = realloc( test_realloc, 32 );
-
-  p4 = _realloc_r( NULL, NULL, 1 );
 }
 
 #define TEST_HEAP_SIZE 2048
@@ -1526,8 +1517,6 @@ static void test_early_malloc( void )
   rtems_test_assert( p != q );
   rtems_test_assert( q[0] == 0 );
 
-  free( q );
-
   r = realloc( q, 128 );
   rtems_test_assert( r == q );
 
-- 
2.31.1



More information about the devel mailing list