testsuite: Fix gcc 12 warnings

This commit is contained in:
Chris Johns
2022-06-20 12:04:43 +10:00
parent 775314d57f
commit 6b2c5b5da1
62 changed files with 96 additions and 89 deletions

View File

@@ -14,7 +14,7 @@
int main(void)
{
struct iovec iov;
struct iovec iov = { 0 };
int count = 4;
ssize_t ret;

View File

@@ -14,7 +14,7 @@
int main(void)
{
sigset_t set;
sigset_t set = { 0 };
int status;
status = sigismember(&set, 21);

View File

@@ -15,7 +15,8 @@
int main(void)
{
int rc;
sigset_t set1, set2;
sigset_t set1 = { 0 };
sigset_t set2 = { 0 };
rc = sigprocmask(SIG_BLOCK, &set1, &set2);
(void) rc;

View File

@@ -14,7 +14,7 @@
int main(void)
{
struct iovec iov;
struct iovec iov = { 0 };
int count = 4;
ssize_t ret;

View File

@@ -32,7 +32,7 @@ int test(void);
int test(void)
{
int af = 0;
struct in_addr addr;
struct in_addr addr = { 0 };
char *dst = "string";
const char *ret = inet_ntop(af, &addr, dst, sizeof(dst));

View File

@@ -5,7 +5,7 @@
/*
* SPDX-License-Identifier: BSD-2-Clause
*
*
* Copyright (C) 2018, Zenon
*
* Redistribution and use in source and binary forms, with or without
@@ -40,7 +40,7 @@ int test(void);
int test(void){
int i0, i1;
char c;
char c = '\0';
i0 = 0;
i1 = 0;

View File

@@ -43,7 +43,7 @@
int test( void )
{
struct hostent *host;
struct in_addr ipv4addr;
struct in_addr ipv4addr = { 0 };
host = gethostbyaddr( &ipv4addr, sizeof(ipv4addr), AF_INET );

View File

@@ -42,8 +42,8 @@ int test( void );
int test( void )
{
pthread_attr_t attribute;
int state;
pthread_attr_t attribute = { 0 };
int state = 0;
int result;
result = pthread_attr_getdetachstate( &attribute, &state );

View File

@@ -42,8 +42,8 @@ int test( void );
int test( void )
{
pthread_attr_t attribute;
size_t size;
pthread_attr_t attribute = { 0 };
size_t size = 0;
int result;
result = pthread_attr_getguardsize( &attribute, &size );

View File

@@ -42,8 +42,8 @@ int test( void );
int test( void )
{
pthread_attr_t attr;
int inheritsched;
pthread_attr_t attr = { 0 };
int inheritsched = 0;
int result;
result = pthread_attr_getinheritsched( &attr, &inheritsched );

View File

@@ -42,8 +42,8 @@ int test( void );
int test( void )
{
pthread_attr_t attr;
struct sched_param param;
pthread_attr_t attr = { 0 };
struct sched_param param = { 0 };
int result;
result = pthread_attr_getschedparam( &attr, &param );

View File

@@ -42,8 +42,8 @@ int test( void );
int test( void )
{
pthread_attr_t attr;
int policy;
pthread_attr_t attr = { 0 };
int policy = 0;
int result;
result = pthread_attr_getschedpolicy( &attr, &policy );

View File

@@ -42,8 +42,8 @@ int test( void );
int test( void )
{
pthread_attr_t attr;
int contentionscope;
pthread_attr_t attr = { 0 };
int contentionscope = 0;
int result;
result = pthread_attr_getscope( &attr, &contentionscope );

View File

@@ -47,7 +47,7 @@ int test( void );
int test( void )
{
pthread_attr_t attribute;
pthread_attr_t attribute = { 0 };
void *stackaddr;
size_t stacksize;
int result;

View File

@@ -47,7 +47,7 @@ int test( void );
int test( void )
{
pthread_attr_t attribute;
pthread_attr_t attribute = { 0 };
void *stackaddr;
int result;

View File

@@ -46,8 +46,8 @@ int test( void );
int test( void )
{
pthread_attr_t attribute;
size_t size;
pthread_attr_t attribute = { 0 };
size_t size = 0;
int result;
result = pthread_attr_getstacksize( &attribute, &size );

View File

@@ -42,8 +42,8 @@ int test( void );
int test( void )
{
pthread_attr_t attr;
struct sched_param param;
pthread_attr_t attr = { 0 };
struct sched_param param = { 0 };
int result;
result = pthread_attr_setschedparam( &attr, &param );

View File

@@ -43,7 +43,7 @@ int test( void );
int test( void )
{
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
pthread_condattr_t attribute;
pthread_condattr_t attribute = { 0 };
int result;
result = pthread_cond_init( &cond, &attribute );

View File

@@ -44,7 +44,7 @@ int test( void )
{
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
struct timespec abstime;
struct timespec abstime = { 0 };
int result;
result = pthread_cond_timedwait( &cond, &mutex, &abstime );

View File

@@ -45,7 +45,7 @@ int test( void );
int test( void )
{
pthread_condattr_t attribute;
pthread_condattr_t attribute = { 0 };
int pshared;
int result;

View File

@@ -53,7 +53,7 @@ void *test_task(
int test( void )
{
pthread_t thread;
pthread_attr_t attribute;
pthread_attr_t attribute = { 0 };
void *arg = NULL;
int result;

View File

@@ -45,8 +45,8 @@ int test( void );
int test( void )
{
pthread_mutex_t mutex;
int prioceiling;
pthread_mutex_t mutex = { 0 };
int prioceiling = 0;
int result;
result = pthread_mutex_getprioceiling( &mutex, &prioceiling );

View File

@@ -43,7 +43,7 @@ int test( void );
int test( void )
{
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_mutexattr_t attribute;
pthread_mutexattr_t attribute = { 0 };
int result;
result = pthread_mutex_init( &mutex, &attribute );

View File

@@ -46,7 +46,7 @@ int test( void );
int test( void )
{
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
struct timespec timeout;
struct timespec timeout = { 0 };
int result;
result = pthread_mutex_timedlock( &mutex, &timeout );

View File

@@ -45,7 +45,7 @@ int test( void );
int test( void )
{
pthread_mutexattr_t attribute;
pthread_mutexattr_t attribute = { 0 };
int prioceiling = 0;
int result;

View File

@@ -45,8 +45,8 @@ int test( void );
int test( void )
{
pthread_mutexattr_t attribute;
int protocol;
pthread_mutexattr_t attribute = { 0 };
int protocol = 0;
int result;
result = pthread_mutexattr_getprotocol( &attribute, &protocol );

View File

@@ -45,8 +45,8 @@ int test( void );
int test( void )
{
pthread_mutexattr_t attribute;
int pshared;
pthread_mutexattr_t attribute = { 0 };
int pshared = 0;
int result;
result = pthread_mutexattr_getpshared( &attribute, &pshared );

View File

@@ -45,8 +45,8 @@ int test( void )
fd_set readfds;
fd_set writefds;
fd_set errorfds;
struct timespec timeout;
sigset_t sigmask;
struct timespec timeout = { 0 };
sigset_t sigmask = { 0 };
return_value = pselect(nfds, &readfds, &writefds, &errorfds, &timeout, &sigmask);
return return_value;

View File

@@ -44,7 +44,7 @@ int test(void);
int test(void)
{
int sockfd = 4;
struct sockaddr addr;
struct sockaddr addr = { 0 };
socklen_t addrlen = sizeof(addr);
return bind(sockfd, &addr, addrlen);

View File

@@ -43,9 +43,9 @@ int test(void);
int test(void)
{
int sockfd = 4;
struct sockaddr addr;
socklen_t addrlen = sizeof(addr);
int sockfd = 4;
struct sockaddr addr = { 0 };
socklen_t addrlen = sizeof(addr);
return connect(sockfd, &addr, addrlen);
}

View File

@@ -48,7 +48,7 @@ int test(void)
int optname = 67;
int value;
void *optval = &value;
socklen_t optlen;
socklen_t optlen = { 0 };
return getsockopt(sockfd, level, optname, optval, &optlen);
}

View File

@@ -44,7 +44,7 @@ ssize_t test(void);
ssize_t test(void)
{
int sockfd = 4;
int buffer;
int buffer = 0;
void *buf = &buffer;
size_t len = sizeof(buffer);
int flags = 7;

View File

@@ -44,7 +44,7 @@ ssize_t test(void);
ssize_t test(void)
{
int sockfd = 4;
struct msghdr msg;
struct msghdr msg = { 0 };
int flags = 7;

View File

@@ -44,11 +44,11 @@ ssize_t test(void);
ssize_t test(void)
{
int sockfd = 4;
int buffer;
int buffer = 0;
const void *buf = &buffer;
size_t len = sizeof(buffer);
int flags = 7;
struct sockaddr dest_addr;
struct sockaddr dest_addr = { 0 };
socklen_t addrlen = sizeof(dest_addr);
return sendto(sockfd, buf, len, flags, &dest_addr, addrlen);

View File

@@ -46,7 +46,7 @@ int test(void)
int sockfd = 4;
int level = SOL_SOCKET;
int optname = 67;
int value;
int value = 0;
void *optval = &value;
socklen_t optlen = sizeof(value);

View File

@@ -42,9 +42,9 @@ int test( void )
{
int return_value;
int fd = 1;
struct timespec times[2];
struct timespec times[2] = { 0 };
return_value = futimens(fd, times);
return (return_value != -1);
}
}

View File

@@ -44,9 +44,9 @@ int test( void )
int return_value;
int fd = 1;
char *path = "/";
struct timespec times[2];
struct timespec times[2] = { 0 };
int flag = AT_SYMLINK_NOFOLLOW;
return_value = utimensat(fd, path, times, flag);
return (return_value != -1);
}
}

View File

@@ -5,7 +5,7 @@
/*
* SPDX-License-Identifier: BSD-2-Clause
*
*
* Copyright (C) 2018, Zenon
*
* Redistribution and use in source and binary forms, with or without
@@ -41,8 +41,8 @@ int test(void);
int test(void)
{
int callback;
struct timeval tv;
callback = utimes(NULL, &tv);
struct timeval tv[2] = { 0 };
callback = utimes(NULL, &tv[0]);
return (callback == -1);
}

View File

@@ -40,11 +40,11 @@ int test( void );
int test( void )
{
struct termios term;
struct termios term = { 0 };
speed_t rate;
rate = cfgetispeed(&term);
(void) rate;
return 0;
}
}

View File

@@ -40,11 +40,11 @@ int test( void );
int test( void )
{
struct termios term;
struct termios term = { 0 };
speed_t rate;
rate = cfgetospeed(&term);
(void) rate;
return 0;
}
}

View File

@@ -41,10 +41,10 @@ int test( void );
int test( void )
{
int result;
struct termios term;
struct termios term = { 0 };
speed_t speed = B0;
result = cfsetispeed(&term, speed);
return result;
}
}

View File

@@ -41,10 +41,10 @@ int test( void );
int test( void )
{
int result;
struct termios term;
struct termios term = { 0 };
speed_t speed = B0;
result = cfsetospeed(&term, speed);
return result;
}
}

View File

@@ -42,9 +42,9 @@ int test( void )
{
int result;
int fildes = 0;
struct termios term;
struct termios term = { 0 };
result = tcgetattr(fildes, &term);
return result;
}
}

View File

@@ -43,9 +43,9 @@ int test( void )
int result;
int fildes = 0;
int optional_actions = 0;
struct termios term;
struct termios term = { 0 };
result = tcsetattr(fildes, optional_actions, &term);
return result;
}
}

View File

@@ -42,7 +42,7 @@ int test( void );
int test( void )
{
char *buffer;
struct tm timestruct;
struct tm timestruct = { 0 };
buffer = asctime( &timestruct );

View File

@@ -42,7 +42,7 @@ int test( void );
int test( void )
{
char *buffer_pointer;
struct tm timestruct;
struct tm timestruct = { 0 };
char buffer[ 80 ];
buffer_pointer = asctime_r( &timestruct, buffer );

View File

@@ -46,7 +46,7 @@ int test( void );
int test( void )
{
clockid_t clock_id = 0;
struct timespec tp;
struct timespec tp = { 0 };
int result;
result = clock_settime( clock_id, &tp );

View File

@@ -42,7 +42,7 @@ int test( void );
int test( void )
{
char *buffer;
time_t time;
time_t time = { 0 };
buffer = ctime( &time );

View File

@@ -43,7 +43,7 @@ int test( void )
{
char *buffer_pointer;
char buffer[ 80 ];
time_t time;
time_t time = { 0 };
buffer_pointer = ctime_r( &time, buffer );

View File

@@ -41,7 +41,7 @@ int test( void );
int test( void )
{
time_t time;
time_t time = { 0 };
struct tm *timestruct;
timestruct = gmtime( &time );

View File

@@ -41,7 +41,7 @@ int test( void );
int test( void )
{
time_t time;
time_t time = { 0 };
struct tm *timestruct_pointer;
struct tm timestruct;

View File

@@ -41,7 +41,7 @@ int test( void );
int test( void )
{
time_t time;
time_t time = { 0 };
struct tm *timestruct;
timestruct = localtime( &time );

View File

@@ -41,7 +41,7 @@ int test( void );
int test( void )
{
time_t time;
time_t time = { 0 };
struct tm *timestruct_pointer;
struct tm timestruct;

View File

@@ -44,7 +44,7 @@ int test( void )
size_t length;
size_t max_length;
char buffer[ 80 ];
struct tm timestruct;
struct tm timestruct = { 0 };
max_length = sizeof( buffer );

View File

@@ -42,7 +42,7 @@ int test( void );
int test( void )
{
gid_t grouplist[ 20 ];
gid_t grouplist[ 20 ] = { 0 } ;
int gidsetsize;
int result;

View File

@@ -43,7 +43,7 @@ int test( void );
int test( void )
{
int result;
const struct utimbuf buff;
const struct utimbuf buff = { 0 };
const char *path = "/tmp/myfile";
result = utime(path, &buff);

View File

@@ -5,7 +5,7 @@
/*
* SPDX-License-Identifier: BSD-2-Clause
*
*
* Copyright (C) 2018, Zenon
*
* Redistribution and use in source and binary forms, with or without
@@ -40,7 +40,7 @@ int test(void);
int test(void)
{
const mbstate_t state;
const mbstate_t state = { 0 };
return mbsinit(&state);
}

View File

@@ -55,6 +55,7 @@ rtems_task Test_Thread(rtems_task_argument argument)
int *value_p, *value_p2;
value_p = malloc( sizeof( int ) );
rtems_test_assert(value_p != NULL);
sc = pthread_setspecific( Key, value_p );
rtems_test_assert( !sc );
@@ -119,7 +120,7 @@ rtems_task Init(rtems_task_argument argument)
pthread_mutex_lock( &mutex1 );
rc = rtems_task_create(
rtems_build_name( 'T', 'E', 'S', 'T' ),
rtems_build_name( 'T', 'E', 'S', 'T' ),
1,
RTEMS_MINIMUM_STACK_SIZE,
RTEMS_DEFAULT_MODES,

View File

@@ -51,7 +51,7 @@ static rtems_name name1, name2;
static rtems_task test_task(rtems_task_argument arg)
{
rtems_status_code sc;
rtems_status_code sc = 0;
const void *value_p;
const void *value_p2;

View File

@@ -1133,7 +1133,7 @@ void verify_with_threads(void)
void validate_mq_setattr(void)
{
struct mq_attr attr;
struct mq_attr attr = { 0 };
struct mq_attr save_attr[ NUMBER_OF_TEST_QUEUES ];
int status;
int i;

View File

@@ -166,7 +166,7 @@ static void obtain_callback(rtems_id timer_id, void *arg)
static void release_callback(rtems_id timer_id, void *arg)
{
rtems_status_code sc = RTEMS_SUCCESSFUL;
char buf [1];
char buf [1] = { 0 };
size_t size = sizeof(buf);
uint32_t released = 0;

View File

@@ -39,6 +39,11 @@
#define FATAL_ERROR_EXPECTED_SOURCE RTEMS_FATAL_SOURCE_INVALID_HEAP_FREE
#define FATAL_ERROR_EXPECTED_ERROR 1
/*
* Disable for the specific test case.
*/
#pragma GCC diagnostic ignored "-Wfree-nonheap-object"
static void force_error(void)
{
uintptr_t invalid = 1;