diff options
author | Aschref Ben Thabet <aschref.ben-thabet@embedded-brains.de> | 2020-08-05 13:54:33 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2020-08-05 14:21:17 +0200 |
commit | 6c4ca834fa943ac462410ad692e85078a2af697d (patch) | |
tree | f237e4ef5a0111f6f8f6e88b1831f58e985891df /testsuites/psxtests/psxhdrs/string/strncpy.c | |
parent | dev/sc16is752: Fix declaration (diff) | |
download | rtems-6c4ca834fa943ac462410ad692e85078a2af697d.tar.bz2 |
psxhdrs/strncpy/stpncpy: Fix string turncation warning
Since we need to test the strncpy function, using a character array with
a fixed array size in this case in place of character pointer can avoid
the string turncation warning.
Diffstat (limited to '')
-rw-r--r-- | testsuites/psxtests/psxhdrs/string/strncpy.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/testsuites/psxtests/psxhdrs/string/strncpy.c b/testsuites/psxtests/psxhdrs/string/strncpy.c index 50b64b3d57..e80d6f6e64 100644 --- a/testsuites/psxtests/psxhdrs/string/strncpy.c +++ b/testsuites/psxtests/psxhdrs/string/strncpy.c @@ -35,16 +35,15 @@ #endif #include <string.h> - int test( void ); int test( void ) { - char *dest = "Hello"; - char *src = "World"; + char src[] = "World"; + char dest[ sizeof( src ) ]; char *result; - result = strncpy( dest, src, 3 ); + result = strncpy( dest, src, sizeof( dest ) ); return ( result != NULL ); } |