<div dir="auto">These are ok. This code is never executed.and these are reasonable changes.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Aug 5, 2020, 6:54 AM Aschref Ben-Thabet <<a href="mailto:aschref.ben-thabet@embedded-brains.de">aschref.ben-thabet@embedded-brains.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Aschref Ben Thabet <<a href="mailto:aschref.ben-thabet@embedded-brains.de" target="_blank" rel="noreferrer">aschref.ben-thabet@embedded-brains.de</a>><br>
<br>
Since we need to test the strncpy function, using a character array with<br>
a fixed array size in this case in place of character pointer can avoid<br>
the string turncation warning.<br>
---<br>
 testsuites/psxtests/psxhdrs/string/stpncpy.c | 7 +++----<br>
 testsuites/psxtests/psxhdrs/string/strncpy.c | 7 +++----<br>
 2 files changed, 6 insertions(+), 8 deletions(-)<br>
<br>
diff --git a/testsuites/psxtests/psxhdrs/string/stpncpy.c b/testsuites/psxtests/psxhdrs/string/stpncpy.c<br>
index f81752de76..f7433a136f 100644<br>
--- a/testsuites/psxtests/psxhdrs/string/stpncpy.c<br>
+++ b/testsuites/psxtests/psxhdrs/string/stpncpy.c<br>
@@ -40,12 +40,11 @@<br>
<br>
  int test( void )<br>
  {<br>
-   char *dest = "Hello world";<br>
-   char *src = "Dude";<br>
-   size_t num = 2;<br>
+   char src[] = "Dude";<br>
+   char dest[ sizeof( src ) ];<br>
    char *result;<br>
<br>
-   result = stpncpy( dest, src, num );<br>
+   result = stpncpy( dest, src, sizeof( dest ) );<br>
<br>
    return ( result != NULL );<br>
  }<br>
diff --git a/testsuites/psxtests/psxhdrs/string/strncpy.c b/testsuites/psxtests/psxhdrs/string/strncpy.c<br>
index 50b64b3d57..e80d6f6e64 100644<br>
--- a/testsuites/psxtests/psxhdrs/string/strncpy.c<br>
+++ b/testsuites/psxtests/psxhdrs/string/strncpy.c<br>
@@ -35,16 +35,15 @@<br>
  #endif<br>
<br>
  #include <string.h><br>
-<br>
  int test( void );<br>
<br>
  int test( void )<br>
  {<br>
-   char *dest = "Hello";<br>
-   char *src = "World";<br>
+   char src[] = "World";<br>
+   char dest[ sizeof( src ) ];<br>
    char *result;<br>
<br>
-   result = strncpy( dest, src, 3 );<br>
+   result = strncpy( dest, src, sizeof( dest ) );<br>
<br>
    return ( result != NULL );<br>
  }<br>
-- <br>
2.26.2<br>
<br>
_______________________________________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org" target="_blank" rel="noreferrer">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
</blockquote></div>