From: Aschref Ben Thabet <aschref.ben-tha...@embedded-brains.de>

replace strncpy with strdup to silence this warning since it tries to
allocate enough memory to hold the old string (plus a '\0' character
to mark the end of the string).
---
 testsuites/psxtests/psxndbm01/init.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/testsuites/psxtests/psxndbm01/init.c 
b/testsuites/psxtests/psxndbm01/init.c
index a13afa7315..cb4d1aca66 100644
--- a/testsuites/psxtests/psxndbm01/init.c
+++ b/testsuites/psxtests/psxndbm01/init.c
@@ -217,10 +217,7 @@ rtems_task Init(rtems_task_argument ignored)
   rtems_test_assert( strcmp( (const char*)get_phone_no.dptr, PHONE_NO2 ) == 0 
);
 
   puts( "Fetch non-existing record and confirm error." );
-  test_strings = (char*)malloc(6);
-  strncpy( test_strings, "Hello", 5 );
-
-  test_strings[5] = '\0';
+  test_strings = strdup( "Hello" );
 
 /* The data pointed by test_string is now pointed by key.dptr */
   key.dptr = test_strings;
-- 
2.26.2

_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Reply via email to