Changeset 6c4ca83 in rtems


Ignore:
Timestamp:
Aug 5, 2020, 11:54:33 AM (7 weeks ago)
Author:
Aschref Ben Thabet <aschref.ben-thabet@…>
Branches:
master
Children:
32f1f747
Parents:
d2c98c1
git-author:
Aschref Ben Thabet <aschref.ben-thabet@…> (08/05/20 11:54:33)
git-committer:
Sebastian Huber <sebastian.huber@…> (08/05/20 12:21:17)
Message:

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.

Location:
testsuites/psxtests/psxhdrs/string
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • testsuites/psxtests/psxhdrs/string/stpncpy.c

    rd2c98c1 r6c4ca83  
    4141 int test( void )
    4242 {
    43    char *dest = "Hello world";
    44    char *src = "Dude";
    45    size_t num = 2;
     43   char src[] = "Dude";
     44   char dest[ sizeof( src ) ];
    4645   char *result;
    4746
    48    result = stpncpy( dest, src, num );
     47   result = stpncpy( dest, src, sizeof( dest ) );
    4948
    5049   return ( result != NULL );
  • testsuites/psxtests/psxhdrs/string/strncpy.c

    rd2c98c1 r6c4ca83  
    3636
    3737 #include <string.h>
    38 
    3938 int test( void );
    4039
    4140 int test( void )
    4241 {
    43    char *dest = "Hello";
    44    char *src = "World";
     42   char src[] = "World";
     43   char dest[ sizeof( src ) ];
    4544   char *result;
    4645
    47    result = strncpy( dest, src, 3 );
     46   result = strncpy( dest, src, sizeof( dest ) );
    4847
    4948   return ( result != NULL );
Note: See TracChangeset for help on using the changeset viewer.