Fix or suppress compiler warnings in posix/conformance/interfaces
cover Fix or suppress compiler warnings in posix/conformance/interfaces
Hi,
this set of patches removed all compiler warnings (at least fog gcc10), for all tests in openposix/conformance/interfaces.
I fixed some real issues in separate patches and a lot of similar problems in bulk patches.
For two categories of warnings I used pragma diagnostic:
- nonnull: Two nonnull warnings are triggered, where the test is used to explicitly test passing NULL. The only way to fix this warning, is to supress it.
- unused-result for write in signal handlers: There is no good way, to handle a failing write-call in a signal handler. Most of the time, the test is exited anyway, so supressing the warning seems like the best fix.
While these pragmas are gcc specific IIRC they also work for clang.
Joerg
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 1/12 posix/pthread_create/15-1: Supress warning
From: Joerg Vehlow <[email protected]>
generate-makefiles.sh gave the following warning:
conformance/interfaces/pthread_create/15-1.c should be test.
The script has a strange implementation, that just greps for "main" in the c file. Based on that it decides if the file should be a test or a run-test. Other tests in the suite including the main-function from testfrmw/threads_scenarii.c also use a comment, that supresses the message
--- .../conformance/interfaces/pthread_create/15-1.c | 1 + 1 file changed, 1 insertion(+)
testcases/open_posix_testsuite/conformance/interfaces/pthread_create/15-1.c +1 -0
@@ -76,6 +76,7 @@/*********************************** Test cases *****************************************/ /********************************************************************************************/ +/* main is defined in the next file */ #define STD_MAIN #include "../testfrmw/threads_scenarii.c"
Signature · 5 lines
2.25.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 01/12] posix/pthread_create/15-1: Supress warning
Hi!
Quoted 4 lines
The script has a strange implementation, that just greps for "main" in the c file. Based on that it decides if the file should be a test or a run-test. Other tests in the suite including the main-function from
testfrmw/threads_scenarii.calso use a comment, that supresses the message
I think that the testfrmw should be cleaned up and rewritten or even better we should get rid of it completely in the long term...
Anyways applied, since this is simple enough.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 2/12 posix/mq_(timed)send/5-1: Fix error reporting
In reply to Joerg VehlowFrom: Joerg Vehlow <[email protected]>
In case mq_receive failed, the whole test could still return PASS/FAIL
--- .../conformance/interfaces/mq_send/5-1.c | 3 +-- .../conformance/interfaces/mq_timedsend/5-1.c | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-)
testcases/open_posix_testsuite/conformance/interfaces/mq_send/5-1.c +1 -2
@@ -68,7 +68,6 @@ int main(void)char msgrcd[BUFFER ];const char *msgptr =MSGSTR ;struct mq_attr attr; -int unresolved =0 ;unsigned pri;sprintf (gqname,"/mq_send_5-1_%d" ,getpid ());
@@ -128,7 +127,7 @@ int main(void)/* receive one message and allow child's mq_send to complete */ if (mq_receive (gqueue, msgrcd,BUFFER , &pri) ==-1 ) {perror ("mq_receive() did not return success" ); - unresolved =1 ; +return cleanup_for_exit (gqueue, gqname,PTS_UNRESOLVED ); }/* child has 5 seconds to call mq_send() again and notify us */
testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c +4 -2
@@ -58,7 +58,6 @@ int main(void)char msgrcd[BUFFER ];const char *msgptr =MSGSTR ;struct mq_attr attr; -int unresolved =0 ;unsigned pri;sprintf (gqname,"/mq_timedsend_5-1_%d" ,getpid ());
@@ -119,7 +118,10 @@ int main(void)/* receive message and allow blocked send to complete */ if (mq_receive (gqueue, msgrcd,BUFFER , &pri) ==-1 ) {perror ("mq_receive() did not return success" ); - unresolved =1 ; +kill (pid,SIGKILL );//kill child +mq_close (gqueue); +mq_unlink (gqname); +return PTS_UNRESOLVED ; }if (sleep (3 ) ==0 ) {
Signature · 5 lines
2.25.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 02/12] posix/mq_(timed)send/5-1: Fix error reporting
Hi!
Applied, thanks.
Quoted 11 lines
testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c +0
-1@@ -58,7 +58,6 @@ int main(void)char msgrcd[BUFFER ];const char *msgptr =MSGSTR ;struct mq_attr attr; -int unresolved =0 ;unsigned pri;sprintf (gqname,"/mq_timedsend_5-1_%d" ,getpid ());
testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c int main(void) · line 125
Quoted 9 lines
testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c +4
-1@@ -119,7 +118,10 @@ int main(void)/* receive message and allow blocked send to complete */ if (mq_receive (gqueue, msgrcd,BUFFER , &pri) ==-1 ) {perror ("mq_receive() did not return success" ); - unresolved =1 ; +kill (pid,SIGKILL );//kill child +mq_close (gqueue); +mq_unlink (gqname); +return PTS_UNRESOLVED ; }
There is another place where it does not clean up the queue in the code under the if (j == MAXMSG+1) condition, that should be fixed as well.
Also I guess the cleanest way how to write this test would be a kernel style goto cleanup. E.g.:
int rval = PTS_UNRESOLVED;
if (foo) {
rval = PTS_FAIL;
goto ret;
}
if (bar)
goto ret;
...
pid = 0;
ret:
if (pid)
kill(pid, SIGKILL);
mq_close(queue);
mq_unlink(queue);
return rval;Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 02/12] posix/mq_(timed)send/5-1: Fix error reporting
Hi Cyril,
Quoted 42 lines · Cyril Hrubis
Hi!
Applied, thanks.Quoted 11 lines
testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c +0
-1@@ -58,7 +58,6 @@ int main(void)char msgrcd[BUFFER ];const char *msgptr =MSGSTR ;struct mq_attr attr; -int unresolved =0 ;unsigned pri;sprintf (gqname,"/mq_timedsend_5-1_%d" ,getpid ());testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c int main(void) · line 125
Quoted 9 lines
testcases/open_posix_testsuite/conformance/interfaces/mq_timedsend/5-1.c +4
-1@@ -119,7 +118,10 @@ int main(void)/* receive message and allow blocked send to complete */ if (mq_receive (gqueue, msgrcd,BUFFER , &pri) ==-1 ) {perror ("mq_receive() did not return success" ); - unresolved =1 ; +kill (pid,SIGKILL );//kill child +mq_close (gqueue); +mq_unlink (gqname); +return PTS_UNRESOLVED ; }There is another place where it does not clean up the queue in the code under the if (j == MAXMSG+1) condition, that should be fixed as well.
Also I guess the cleanest way how to write this test would be a kernel style goto cleanup. E.g.:
int rval = PTS_UNRESOLVED; if (foo) { rval = PTS_FAIL; goto ret; } if (bar) goto ret; ...
Quoted 7 lines
pid = 0; ret: if (pid) kill(pid, SIGKILL); mq_close(queue); mq_unlink(queue); return rval;
You are right, but I wanted to keep changes minimal. I think there are lots of small bug in the posix tests, but fixing all of them while trying to just get rid of warnings, would have made this patchset even bigger and I would have never finished. So I had to stop somewhere.
Joerg
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 02/12] posix/mq_(timed)send/5-1: Fix error reporting
Hi!
Quoted 5 lines
You are right, but I wanted to keep changes minimal. I think there are lots of small bug in the posix tests,
but fixing all of them while trying to just get rid of warnings, would have made this patchset even bigger and
I would have never finished. So I had to stop somewhere.
Understood, looking forward to a next patchset then :-).
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 3/12 posix/pthread_create/*: Remove unused variable
In reply to Joerg VehlowFrom: Joerg Vehlow <[email protected]>
While pad was supposed to speed up stack growth, the test works without it and it was propably optimized out anyway.
--- .../conformance/interfaces/pthread_create/1-5.c | 3 --- .../conformance/interfaces/pthread_create/3-2.c | 2 -- 2 files changed, 5 deletions(-)
testcases/open_posix_testsuite/conformance/interfaces/pthread_create/1-5.c +0 -3
@@ -100,12 +100,9 @@static void *overflow (void *arg) {void *current; -void *pad[50 ];/* We want to consume the stack quickly */ long stacksize =sysconf (_SC_THREAD_STACK_MIN);/* make sure we touch the current stack memory */ int ret =0 ; - pad[1 ] =NULL ;/* so compiler stops complaining about unused variables */ -if (arg ==NULL ) {/* first call */ current =overflow (¤t);
testcases/open_posix_testsuite/conformance/interfaces/pthread_create/3-2.c +0 -2
@@ -108,10 +108,8 @@ static sem_t semsync[2]; /* These semaphores will only be used in child processstatic void *overflow (void *arg) {void *current; -void *pad[50 ];/* We want to consume the stack quickly */ long stacksize =sysconf (_SC_THREAD_STACK_MIN);/* make sure we touch the current stack memory */ - pad[1 ] =NULL ;/* so compiler stops complaining about unused variables */ int ret =0 ;if (arg ==NULL ) {
Signature · 5 lines
2.25.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 03/12] posix/pthread_create/*: Remove unused variable
Hi!
Applied, thanks.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 4/12 posix/conformance/interfaces: Fix unsued-variable for testfrmw
In reply to Joerg VehlowFrom: Joerg Vehlow <[email protected]>
Thre is a global variable sc in testfrmw/threads_scenarii, that is used, if the integrated main function (STD_MAIN) is used. However some tests did not use this integrated main, but still used the variable. To be able to get rid of all warnings, the variable is duplicated into these tests and only defined by threads_scenarii, if STD_MAIN is defined
--- .../conformance/interfaces/pthread_create/14-1.c | 2 ++ .../conformance/interfaces/pthread_create/3-2.c | 2 ++ .../conformance/interfaces/pthread_detach/1-2.c | 2 ++ .../conformance/interfaces/pthread_detach/2-2.c | 1 + .../conformance/interfaces/pthread_detach/4-3.c | 1 + .../conformance/interfaces/pthread_exit/6-1.c | 1 + .../conformance/interfaces/pthread_join/1-2.c | 2 ++ .../conformance/interfaces/pthread_join/4-1.c | 1 + .../conformance/interfaces/pthread_join/6-3.c | 1 + .../conformance/interfaces/testfrmw/threads_scenarii.c | 4 ++-- 10 files changed, 15 insertions(+), 2 deletions(-)
testcases/open_posix_testsuite/conformance/interfaces/pthread_create/14-1.c +2 -0
@@ -47,6 +47,8 @@ static volatile long sleep_time;/* number of pthread_create scenarios tested */ static unsigned long count_ope; +static unsigned int sc; +static unsigned long long current_time_usec (void ) {struct timeval now;
testcases/open_posix_testsuite/conformance/interfaces/pthread_create/3-2.c +2 -0
@@ -104,6 +104,8 @@static sem_t semsync[2 ];/* These semaphores will only be used in child process! */ +static unsigned int sc; +/* The overflow function is used to test the stack overflow */ static void *overflow (void *arg) {
testcases/open_posix_testsuite/conformance/interfaces/pthread_detach/1-2.c +2 -0
@@ -91,6 +91,8 @@/*********************************** Real Test *****************************************/ /********************************************************************************************/ +static unsigned int sc; +static void *threaded (void *arg) {int ret =0 ;
testcases/open_posix_testsuite/conformance/interfaces/pthread_detach/2-2.c +1 -0
@@ -93,6 +93,7 @@/********************************************************************************************/ static sem_t sem_sync; +static unsigned int sc;static void *threaded (void *arg) {
testcases/open_posix_testsuite/conformance/interfaces/pthread_detach/4-3.c +1 -0
@@ -61,6 +61,7 @@ static sem_t semsig1;static unsigned long count_sig;static long sleep_time;static sigset_t usersigs; +static unsigned int sc;struct thestruct {int sig;
testcases/open_posix_testsuite/conformance/interfaces/pthread_exit/6-1.c +1 -0
@@ -98,6 +98,7 @@/* This will be used to control that atexit() has been called */ static int *ctl;static long mf; +static unsigned int sc;static void clnp (void ) {
testcases/open_posix_testsuite/conformance/interfaces/pthread_join/1-2.c +2 -0
@@ -48,6 +48,8 @@#include "../testfrmw/threads_scenarii.c" +static unsigned int sc; +static void *threaded (void *arg) {int ret =0 ;
testcases/open_posix_testsuite/conformance/interfaces/pthread_join/4-1.c +1 -0
@@ -46,6 +46,7 @@#include "../testfrmw/threads_scenarii.c" static pthread_mutex_t mtx =PTHREAD_MUTEX_INITIALIZER ; +static unsigned int sc;/* 1st thread function */ static void *threaded(void *arg PTS_ATTRIBUTE_UNUSED)
testcases/open_posix_testsuite/conformance/interfaces/pthread_join/6-3.c +1 -0
@@ -56,6 +56,7 @@ static unsigned long count_sig;#endif static sigset_t usersigs; +static unsigned int sc;struct thestruct {int sig;
testcases/open_posix_testsuite/conformance/interfaces/testfrmw/threads_scenarii.c +2 -2
@@ -482,10 +482,10 @@ static void scenar_fini(void) } } -static unsigned int sc; -#ifdef STD_MAIN +static unsigned int sc; +static void *threaded (void *arg);int main (void )
Signature · 5 lines
2.25.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 04/12] posix/conformance/interfaces: Fix unsued-variable for testfrmw
Hi!
Applied, thanks.
But still fixing warnings in the testfrmw this way feels like we are putting a lipstick on a pig. Large scale cleanup of the code is needed and the warnings were really harmless in this case...
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 04/12] posix/conformance/interfaces: Fix unsued-variable for testfrmw
Hi Cyril,
Quoted 6 lines · Cyril Hrubis
Hi!
Applied, thanks.But still fixing warnings in the testfrmw this way feels like we are putting a lipstick on a pig. Large scale cleanup of the code is needed and the warnings were really harmless in this case...
Yes as I wrote already, I wanted to start somewhere and the warning clutter hid already some warnings, that indicated real programming errors. So I wanted to get rid of them. Additionally the compiler output is to be inspected, because some test are just compile-time tests.
A one-shot cleanup of all tests is also probably not feasible, so iterative cleanup with clean warnings should be easier.
Joerg
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 5/12 posix/conformance/interfaces: Fix all unused variable warnings
In reply to Joerg VehlowFrom: Joerg Vehlow <[email protected]>
Either by marking them as unused or by removing them, if there is no sideffect.
--- .../conformance/interfaces/aio_read/9-1.c | 3 +-- .../conformance/interfaces/aio_write/7-1.c | 3 +-- .../open_posix_testsuite/conformance/interfaces/fork/7-1.c | 2 +- .../conformance/interfaces/pthread_cond_init/2-1.c | 2 +- .../conformance/interfaces/pthread_exit/2-2.c | 2 +- .../conformance/interfaces/pthread_exit/3-2.c | 2 +- .../conformance/interfaces/pthread_mutex_init/3-1.c | 4 ++-- .../conformance/interfaces/pthread_mutex_timedlock/4-1.c | 4 +--- .../conformance/interfaces/pthread_mutex_timedlock/5-1.c | 4 +--- .../conformance/interfaces/pthread_mutex_timedlock/5-2.c | 4 +--- .../conformance/interfaces/pthread_mutex_timedlock/5-3.c | 4 +--- .../conformance/interfaces/pthread_mutex_trylock/4-3.c | 1 - .../conformance/interfaces/pthread_mutex_unlock/2-1.c | 4 ++-- .../conformance/interfaces/pthread_mutexattr_setpshared/1-1.c | 2 -- .../conformance/interfaces/pthread_once/4-1-buildonly.c | 3 ++- 15 files changed, 16 insertions(+), 28 deletions(-)
testcases/open_posix_testsuite/conformance/interfaces/aio_read/9-1.c +1 -2
@@ -48,7 +48,6 @@ int main(void)int i;struct aiocb aiocbs[NUM_AIOCBS ];int last_req; -int err;int ret; if (sysconf(_SC_ASYNCHRONOUS_IO) < 200112L
@@ -85,7 +84,7 @@ int main(void) }for (i =0 ; i < last_req -1 ; i++) { - err =aio_error (&aiocbs[i]); +aio_error (&aiocbs[i]); ret =aio_return (&aiocbs[i]); }
testcases/open_posix_testsuite/conformance/interfaces/aio_write/7-1.c +1 -2
@@ -48,7 +48,6 @@ int main(void)int i;struct aiocb aiocbs[NUM_AIOCBS ];int last_req; -int err;int ret; if (sysconf(_SC_ASYNCHRONOUS_IO) < 200112L
@@ -79,7 +78,7 @@ int main(void) }for (i =0 ; i < last_req -1 ; i++) { - err =aio_error (&aiocbs[i]); +aio_error (&aiocbs[i]); ret =aio_return (&aiocbs[i]); }
testcases/open_posix_testsuite/conformance/interfaces/fork/7-1.c +1 -1
@@ -51,7 +51,7 @@static void read_catalog (nl_catd cat,char *who) { -char *msg =NULL ; + char *msg PTS_ATTRIBUTE_UNUSED = NULL;int i, j;#if VERBOSE >0
testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_init/2-1.c +1 -1
@@ -14,7 +14,7 @@#include <stdio.h> #include "posixtest.h" -static pthread_cond_t cond =PTHREAD_COND_INITIALIZER ; +static pthread_cond_t cond PTS_ATTRIBUTE_UNUSED = PTHREAD_COND_INITIALIZER;int main (void ) {
testcases/open_posix_testsuite/conformance/interfaces/pthread_exit/2-2.c +1 -1
@@ -92,7 +92,7 @@static int global =0 ;static int tab[3 ]; -#define CLEANUP (n) static void clnp##n(void * arg)\ +#define CLEANUP (n) static void clnp##n(void * arg PTS_ATTRIBUTE_UNUSED)\ {\ tab[global]=n; \ global++; \
testcases/open_posix_testsuite/conformance/interfaces/pthread_exit/3-2.c +1 -1
@@ -94,7 +94,7 @@ static int global = 0;static int tab[4 ];static pthread_key_t tld[3 ]; -#define CLEANUP (n) static void clnp##n(void * arg)\ +#define CLEANUP (n) static void clnp##n(void * arg PTS_ATTRIBUTE_UNUSED)\ {\ tab[global]=n; \ global++; \
testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_init/3-1.c +2 -2
@@ -5,7 +5,7 @@* of this license, see the COPYING file at the top level of this * source tree. -* Test that the macro PTHREAD_MUTEX_INITIALIZER can be sued to intiailize +* Test that the macro PTHREAD_MUTEX_INITIALIZER can be used to initialize * mutexes that are statically allocated. * */
@@ -20,7 +20,7 @@ typedef struct my_data {int value;/* Access protected by mutex */ } my_data_t; -static my_data_t data = {PTHREAD_MUTEX_INITIALIZER ,0 }; +static my_data_t data PTS_ATTRIBUTE_UNUSED = { PTHREAD_MUTEX_INITIALIZER, 0 };int main (void ) {
testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/4-1.c +1 -3
@@ -32,9 +32,7 @@ static void *f1(void *parm);static int ret;/* Save return value of pthread_mutex_timedlock(). */ static pthread_mutex_t mutex =PTHREAD_MUTEX_INITIALIZER ;/* The mutex */ -static time_t currsec1, currsec2;/* Variables for saving time before -and afer locking the mutex using -pthread_mutex_timedlock(). */ +/**************************** * * MAIN()
testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/5-1.c +1 -3
@@ -40,9 +40,7 @@ static void *f1(void *parm);static int ret;/* Save return value of pthread_mutex_timedlock(). */ static pthread_mutex_t mutex =PTHREAD_MUTEX_INITIALIZER ;/* The mutex */ -static time_t currsec1, currsec2;/* Variables for saving time before -and afer locking the mutex using -pthread_mutex_timedlock(). */ +/**************************** * * MAIN()
testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/5-2.c +1 -3
@@ -40,9 +40,7 @@ static void *f1(void *parm);static int ret;/* Save return value of pthread_mutex_timedlock(). */ static pthread_mutex_t mutex =PTHREAD_MUTEX_INITIALIZER ;/* The mutex */ -static time_t currsec1, currsec2;/* Variables for saving time before -and afer locking the mutex using -pthread_mutex_timedlock(). */ +/**************************** * * MAIN()
testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/5-3.c +1 -3
@@ -36,9 +36,7 @@ static void *f1(void *parm);static int ret;/* Save return value of pthread_mutex_timedlock(). */ static pthread_mutex_t mutex =PTHREAD_MUTEX_INITIALIZER ;/* The mutex */ -static time_t currsec1, currsec2;/* Variables for saving time before -and afer locking the mutex using -pthread_mutex_timedlock(). */ +/**************************** * * MAIN()
testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_trylock/4-3.c +0 -1
@@ -103,7 +103,6 @@ static struct _scenar {#define NSCENAR (sizeof(scenarii)/sizeof(scenarii[0]))static char do_it =1 ; -static char woken =0 ;static unsigned long count_ope =0 ;#ifdef WITH_SYNCHRO static sem_t semsig1;
testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_unlock/2-1.c +2 -2
@@ -39,13 +39,13 @@ static int value; /* value protected by mutex */int main (void ) { -int i, rc; +int i;pthread_t threads[THREAD_NUM ];/* Create threads */ fprintf (stderr,"Creating %d threads\n" ,THREAD_NUM );for (i =0 ; i <THREAD_NUM ; ++i) - rc =pthread_create (&threads[i],NULL , func,NULL ); +pthread_create (&threads[i],NULL , func,NULL );/* Wait to join all threads */ for (i =0 ; i <THREAD_NUM ; ++i)
testcases/open_posix_testsuite/conformance/interfaces/pthread_mutexattr_setpshared/1-1.c +0 -2
@@ -37,8 +37,6 @@#include <stdio.h> #include "posixtest.h" -static pthread_mutex_t new_mutex;/* The mutex. */ -int main (void ) {pthread_mutexattr_t mta;
testcases/open_posix_testsuite/conformance/interfaces/pthread_once/4-1-buildonly.c +2 -1
@@ -11,5 +11,6 @@*/ #include <pthread.h> +#include "posixtest.h" -static pthread_once_t dummy =PTHREAD_ONCE_INIT ; +static pthread_once_t dummy PTS_ATTRIBUTE_UNUSED = PTHREAD_ONCE_INIT;
Signature · 5 lines
2.25.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 05/12] posix/conformance/interfaces: Fix all unused variable warnings
Hi!
Quoted 13 lines
testcases/open_posix_testsuite/conformance/interfaces/aio_read/9-1.c +0
-1@@ -48,7 +48,6 @@ int main(void)int i;struct aiocb aiocbs[NUM_AIOCBS ];int last_req; -int err;int ret; if (sysconf(_SC_ASYNCHRONOUS_IO) < 200112L
testcases/open_posix_testsuite/conformance/interfaces/aio_read/9-1.c int main(void) · line 90
Quoted 8 lines
testcases/open_posix_testsuite/conformance/interfaces/aio_read/9-1.c +1
-1@@ -85,7 +84,7 @@ int main(void) }for (i =0 ; i < last_req -1 ; i++) { - err =aio_error (&aiocbs[i]); +aio_error (&aiocbs[i]); ret =aio_return (&aiocbs[i]); }
Looking at the test the whole loop here is pointless, can we remove it completely?
Quoted 13 lines
testcases/open_posix_testsuite/conformance/interfaces/aio_write/7-1.c +0
-1@@ -48,7 +48,6 @@ int main(void)int i;struct aiocb aiocbs[NUM_AIOCBS ];int last_req; -int err;int ret; if (sysconf(_SC_ASYNCHRONOUS_IO) < 200112L
testcases/open_posix_testsuite/conformance/interfaces/aio_write/7-1.c int main(void) · line 84
Quoted 8 lines
testcases/open_posix_testsuite/conformance/interfaces/aio_write/7-1.c +1
-1@@ -79,7 +78,7 @@ int main(void) }for (i =0 ; i < last_req -1 ; i++) { - err =aio_error (&aiocbs[i]); +aio_error (&aiocbs[i]); ret =aio_return (&aiocbs[i]); }
Here as well.
testcases/open_posix_testsuite/conformance/interfaces/fork/7-1.c line 55
Quoted 11 lines
testcases/open_posix_testsuite/conformance/interfaces/fork/7-1.c +1
-1@@ -51,7 +51,7 @@static void read_catalog (nl_catd cat,char *who) { -char *msg =NULL ; + char *msg PTS_ATTRIBUTE_UNUSED = NULL;int i, j;
I guess that in this case the test is wrong as well. It does not seem that catgets() fails when it returns the pointer to the "not found" string and does not even touch errno.
testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_init/2-1.c line 17
Quoted 11 lines
testcases/open_posix_testsuite/conformance/interfaces/fork/7-1.c +0
-0#if VERBOSE >0 testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_init/2-1.c +1
-1@@ -14,7 +14,7 @@#include <stdio.h> #include "posixtest.h" -static pthread_cond_t cond =PTHREAD_COND_INITIALIZER ; +static pthread_cond_t cond PTS_ATTRIBUTE_UNUSED = PTHREAD_COND_INITIALIZER;
This one looks fine.
Quoted 20 lines
testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_init/2-1.c +0
-0int main (void ) {testcases/open_posix_testsuite/conformance/interfaces/pthread_exit/2-2.c +1
-1@@ -92,7 +92,7 @@static int global =0 ;static int tab[3 ]; -#define CLEANUP (n) static void clnp##n(void * arg)\ +#define CLEANUP (n) static void clnp##n(void * arg PTS_ATTRIBUTE_UNUSED)\ {\ tab[global]=n; \ global++; \testcases/open_posix_testsuite/conformance/interfaces/pthread_exit/3-2.c +0
-0
testcases/open_posix_testsuite/conformance/interfaces/pthread_exit/3-2.c static int global = 0; · line 100
Quoted 8 lines
testcases/open_posix_testsuite/conformance/interfaces/pthread_exit/3-2.c +1
-1@@ -94,7 +94,7 @@ static int global = 0;static int tab[4 ];static pthread_key_t tld[3 ]; -#define CLEANUP (n) static void clnp##n(void * arg)\ +#define CLEANUP (n) static void clnp##n(void * arg PTS_ATTRIBUTE_UNUSED)\ {\ tab[global]=n; \ global++; \
THese two as well.
Quoted 14 lines
testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_init/3-1.c +1
-1@@ -5,7 +5,7 @@* of this license, see the COPYING file at the top level of this * source tree. -* Test that the macro PTHREAD_MUTEX_INITIALIZER can be sued to intiailize +* Test that the macro PTHREAD_MUTEX_INITIALIZER can be used to initialize * mutexes that are statically allocated. * */
testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_init/3-1.c typedef struct my_data { · line 26
Quoted 8 lines
testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_init/3-1.c +1
-1@@ -20,7 +20,7 @@ typedef struct my_data {int value;/* Access protected by mutex */ } my_data_t; -static my_data_t data = {PTHREAD_MUTEX_INITIALIZER ,0 }; +static my_data_t data PTS_ATTRIBUTE_UNUSED = { PTHREAD_MUTEX_INITIALIZER, 0 };int main (void ) {
This one as well.
Quoted 50 lines
testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/4-1.c +1
-3@@ -32,9 +32,7 @@ static void *f1(void *parm);static int ret;/* Save return value of pthread_mutex_timedlock(). */ static pthread_mutex_t mutex =PTHREAD_MUTEX_INITIALIZER ;/* The mutex */ -static time_t currsec1, currsec2;/* Variables for saving time before -and afer locking the mutex using -pthread_mutex_timedlock(). */ +/**************************** * * MAIN() testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/5-1.c +1
-3@@ -40,9 +40,7 @@ static void *f1(void *parm);static int ret;/* Save return value of pthread_mutex_timedlock(). */ static pthread_mutex_t mutex =PTHREAD_MUTEX_INITIALIZER ;/* The mutex */ -static time_t currsec1, currsec2;/* Variables for saving time before -and afer locking the mutex using -pthread_mutex_timedlock(). */ +/**************************** * * MAIN() testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/5-2.c +1
-3@@ -40,9 +40,7 @@ static void *f1(void *parm);static int ret;/* Save return value of pthread_mutex_timedlock(). */ static pthread_mutex_t mutex =PTHREAD_MUTEX_INITIALIZER ;/* The mutex */ -static time_t currsec1, currsec2;/* Variables for saving time before -and afer locking the mutex using -pthread_mutex_timedlock(). */ +/**************************** * * MAIN() testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/5-3.c +0
-0
testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/5-3.c static void *f1(void *parm); · line 42
Quoted 10 lines
testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_timedlock/5-3.c +1
-3@@ -36,9 +36,7 @@ static void *f1(void *parm);static int ret;/* Save return value of pthread_mutex_timedlock(). */ static pthread_mutex_t mutex =PTHREAD_MUTEX_INITIALIZER ;/* The mutex */ -static time_t currsec1, currsec2;/* Variables for saving time before -and afer locking the mutex using -pthread_mutex_timedlock(). */ +/**************************** * * MAIN()
This part as well.
Quoted 22 lines
testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_trylock/4-3.c +0
-1@@ -103,7 +103,6 @@ static struct _scenar {#define NSCENAR (sizeof(scenarii)/sizeof(scenarii[0]))static char do_it =1 ; -static char woken =0 ;static unsigned long count_ope =0 ;#ifdef WITH_SYNCHRO static sem_t semsig1;testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_unlock/2-1.c +1
-1@@ -39,13 +39,13 @@ static int value; /* value protected by mutex */int main (void ) { -int i, rc; +int i;
testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_unlock/2-1.c static int value; /* value protected by mutex */ · line 51
Quoted 10 lines
testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_unlock/2-1.c +1
-1pthread_t threads[THREAD_NUM ];/* Create threads */ fprintf (stderr,"Creating %d threads\n" ,THREAD_NUM );for (i =0 ; i <THREAD_NUM ; ++i) - rc =pthread_create (&threads[i],NULL , func,NULL ); +pthread_create (&threads[i],NULL , func,NULL );/* Wait to join all threads */ for (i =0 ; i <THREAD_NUM ; ++i)
Well technically we should check the return value, but this is better than it was before.
Quoted 18 lines
testcases/open_posix_testsuite/conformance/interfaces/pthread_mutexattr_setpshared/1-1.c +0
-2@@ -37,8 +37,6 @@#include <stdio.h> #include "posixtest.h" -static pthread_mutex_t new_mutex;/* The mutex. */ -int main (void ) {pthread_mutexattr_t mta;testcases/open_posix_testsuite/conformance/interfaces/pthread_once/4-1-buildonly.c +0
-0
testcases/open_posix_testsuite/conformance/interfaces/pthread_once/4-1-buildonly.c line 16
Quoted 7 lines
testcases/open_posix_testsuite/conformance/interfaces/pthread_once/4-1-buildonly.c +2
-1@@ -11,5 +11,6 @@*/ #include <pthread.h> +#include "posixtest.h" -static pthread_once_t dummy =PTHREAD_ONCE_INIT ; +static pthread_once_t dummy PTS_ATTRIBUTE_UNUSED = PTHREAD_ONCE_INIT;
And these two are fine as well.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 05/12] posix/conformance/interfaces: Fix all unused variable warnings
Hi Cyril,
Quoted 16 lines · Cyril Hrubis
Hi!
Quoted 15 lines
testcases/open_posix_testsuite/conformance/interfaces/aio_read/9-1.c +0
-1@@ -48,7 +48,6 @@ int main(void)int i;struct aiocb aiocbs[NUM_AIOCBS ];int last_req; -int err;int ret; if (sysconf(_SC_ASYNCHRONOUS_IO) < 200112L@@ -85,7 +84,7 @@ int main(void) }
Quoted 8 lines
testcases/open_posix_testsuite/conformance/interfaces/aio_read/9-1.c int main(void) · line 90
Quoted 6 lines
testcases/open_posix_testsuite/conformance/interfaces/aio_read/9-1.c +1
-1for (i =0 ; i < last_req -1 ; i++) { - err =aio_error (&aiocbs[i]); +aio_error (&aiocbs[i]); ret =aio_return (&aiocbs[i]); }Looking at the test the whole loop here is pointless, can we remove it completely?
I thought the same, but I have never used aio, so I have no clue, if there are any side effects. So I went for a minimal change approach.
Quoted 6 lines
Quoted 6 lines
testcases/open_posix_testsuite/conformance/interfaces/fork/7-1.c +0
-0@@ -51,7 +51,7 @@
Quoted 8 lines
testcases/open_posix_testsuite/conformance/interfaces/fork/7-1.c line 55
Quoted 5 lines
testcases/open_posix_testsuite/conformance/interfaces/fork/7-1.c +1
-1static void read_catalog (nl_catd cat,char *who) { -char *msg =NULL ; + char *msg PTS_ATTRIBUTE_UNUSED = NULL;int i, j;I guess that in this case the test is wrong as well. It does not seem that
catgets()fails when it returns the pointer to the "not found" string and does not even touch errno.
Yes looks like you are right. Looks like this test can never fail.
I would fix it like this in a next revision:
testcases/open_posix_testsuite/conformance/interfaces/fork/7-1.c +0 -0
@@ -49,33 +49,22 @@
#define MESSCAT_IN "messcat.txt"
#define MESSCAT_OUT "messcat.cat"
-static void read_catalog(nl_catd cat, char *who)
+static int read_catalog(nl_catd cat)
{
+ static const char *notfound = "not found";
char *msg PTS_ATTRIBUTE_UNUSED = NULL;
int i, j;
-#if VERBOSE > 0
- output("Reading the message catalog from %s...\n", who); -#endif
-
- errno = 0;
-
for (i = 1; i <= 2; i++) {
for (j = 1; j <= 2; j++) {
- msg = catgets(cat, i, j, "not found");
-
- if (errno != 0)
- UNRESOLVED(errno, "catgets returned an error"); -#if VERBOSE > 1
- output("set %i msg %i: %s\n", i, j, msg); -#endif
+ msg = catgets(cat, i, j, notfound);
+ if (msg == notfound) {
+ return 1;
+ }
}
}
-
-#if VERBOSE > 0
- output("Message catalog read successfully in %s\n", who); -#endif
+ return 0;
}
static char *messcat_in =
@@ -132,7 +121,10 @@ int main(void)
if (messcat == (nl_catd) - 1) UNRESOLVED(errno, "Could not open ./" MESSCAT_OUT);
- read_catalog(messcat, "parent");
+ if (read_catalog(messcat)) {
+ printf("UNRESOLVED: Unable to read message catalog in parent"); + return PTS_UNRESOLVED;
+ }
child = fork();
@@ -140,8 +132,11 @@ int main(void)
UNRESOLVED(errno, "Failed to fork");
if (child == 0) {
- read_catalog(messcat, "child");
- exit(PTS_PASS);
+ if (read_catalog(messcat)) {
+ printf("FAILED: Unable to read message catalog in child"); + return PTS_FAIL;
+ }
+ return PTS_PASS;
}
ctl = waitpid(child, &status, 0);
Joerg
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 05/12] posix/conformance/interfaces: Fix all unused variable warnings
Hi!
Quoted 4 lines
Quoted 2 lines
Looking at the test the whole loop here is pointless, can we remove it completely?
I thought the same, but I have never used aio, so I have no clue, if there are any side effects.
As far as I can tell there is none. I guess that the original test author was simply clueless, we used to have much more code that didn't made any sense ten years ago and you can still occasionally find some...
Quoted 1 line
So I went for a minimal?? change approach.
Let's go for that for now then. It would be nice to fix it properly later on.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 6/12 posix/conformance/interfaces: Fix all unused function warnings
In reply to Joerg VehlowFrom: Joerg Vehlow <[email protected]>
--- .../conformance/interfaces/pthread_attr_setstack/6-1.c | 6 ------ .../conformance/interfaces/pthread_attr_setstack/7-1.c | 6 ------ .../interfaces/pthread_attr_setstacksize/4-1.c | 6 ------ .../conformance/interfaces/pthread_exit/4-1.c | 9 ++------- .../conformance/interfaces/pthread_exit/5-1.c | 7 +------ .../conformance/interfaces/pthread_kill/8-1.c | 8 -------- .../conformance/interfaces/pthread_mutex_lock/1-1.c | 4 ++-- .../conformance/interfaces/pthread_sigmask/18-1.c | 8 -------- 8 files changed, 5 insertions(+), 49 deletions(-)
testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setstack/6-1.c +0 -6
@@ -31,12 +31,6 @@static void *stack_addr;static size_t stack_size; -static void *thread_func () -{ -pthread_exit (0 ); -return NULL ; -} -int main (void ) {pthread_attr_t attr;
testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setstack/7-1.c +0 -6
@@ -32,12 +32,6 @@static void *stack_addr;static size_t stack_size; -static void *thread_func () -{ -pthread_exit (0 ); -return NULL ; -} -int main (void ) {pthread_attr_t attr;
testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setstacksize/4-1.c +0 -6
@@ -28,12 +28,6 @@#define STACKSIZE PTHREAD_STACK_MIN - sysconf(_SC_PAGE_SIZE) -static void *thread_func () -{ -pthread_exit (0 ); -return NULL ; -} -int main (void ) {pthread_attr_t attr;
testcases/open_posix_testsuite/conformance/interfaces/pthread_exit/4-1.c +2 -7
@@ -91,12 +91,7 @@static int global =0 ; -/* atexit() routines */ -static void at1 (void ) -{ - global +=1 ; -} - +/* atexit() routine */ static void at2 (void ) { global +=2 ;
@@ -107,7 +102,7 @@ static void *threaded(void *arg PTS_ATTRIBUTE_UNUSED) {int ret =0 ; -/* Note that this funtion will be registered once again for each scenario. +/* Note that this function will be registered once again for each scenario. POSIX requires the ability to register at least 32 functions so it should not be an issue in our case, as long as we don't get more than 32 scenarii (with joinable threads) */
testcases/open_posix_testsuite/conformance/interfaces/pthread_exit/5-1.c +1 -6
@@ -91,12 +91,7 @@static int atctl =0 ;static pthread_key_t tld[3 ]; -/* atexit() routines */ -static void at1 (void ) -{ - atctl +=1 ; -} - +/* atexit() routine */ static void at2 (void ) { atctl +=2 ;
testcases/open_posix_testsuite/conformance/interfaces/pthread_kill/8-1.c +0 -8
@@ -153,14 +153,6 @@ static void sighdl2(int sig PTS_ATTRIBUTE_UNUSED)#endif } -static int init_ctl; -/* Init function */ -static void initializer (void ) -{ - init_ctl++; -return ; -} -/* Test function -- calls pthread_kill() and checks that EINTR is never returned. */ static void *test(void *arg PTS_ATTRIBUTE_UNUSED) {
testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_lock/1-1.c +2 -2
@@ -36,7 +36,7 @@ static int value; /* value protected by mutex */int main (void ) { -int i, rc; +int i;pthread_attr_t pta;pthread_t threads[THREAD_NUM ];//pthread_t self = pthread_self();
@@ -47,7 +47,7 @@ int main(void)/* Create threads */ fprintf (stderr,"Creating %d threads\n" ,THREAD_NUM );for (i =0 ; i <THREAD_NUM ; ++i) - rc =pthread_create (&threads[i], &pta, f1,NULL ); +pthread_create (&threads[i], &pta, f1,NULL );/* Wait to join all threads */ for (i =0 ; i <THREAD_NUM ; ++i)
testcases/open_posix_testsuite/conformance/interfaces/pthread_sigmask/18-1.c +0 -8
@@ -153,14 +153,6 @@ static void sighdl2(int sig PTS_ATTRIBUTE_UNUSED)#endif } -static int init_ctl; -/* Init function */ -static void initializer (void ) -{ - init_ctl++; -return ; -} -/* Test function -- calls pthread_sigmask() and checks that EINTR is never returned. */ static void *test(void *arg PTS_ATTRIBUTE_UNUSED) {
Signature · 5 lines
2.25.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 06/12] posix/conformance/interfaces: Fix all unused function warnings
Hi!
Applied, thanks.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 7/12 posix/pthread_key_create/2-1: Remove invalid part of test
In reply to Joerg VehlowFrom: Joerg Vehlow <[email protected]>
The first step accroding to the test description is: "Create a key", but the code was "get the value for an unitialized key". This was undefined behavior.
--- .../conformance/interfaces/pthread_key_create/2-1.c | 7 ------- 1 file changed, 7 deletions(-)
testcases/open_posix_testsuite/conformance/interfaces/pthread_key_create/2-1.c +0 -7
@@ -28,13 +28,6 @@ int main(void)pthread_key_t key;void *rc; -/* Verify that the value associated with "key" in a new thread is NULL */ - rc =pthread_getspecific (key); -if (rc !=NULL ) { -printf ("Test FAILED\n" ); -return PTS_FAIL ; - } -if (pthread_key_create (&key,NULL ) !=0 ) {printf ("Error: pthread_key_create() failed\n" );return PTS_UNRESOLVED ;
Signature · 5 lines
2.25.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 07/12] posix/pthread_key_create/2-1: Remove invalid part of test
Hi!
Applied, thanks.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 8/12 posix/asctime: Fix potentioal buffer overflow
In reply to Joerg VehlowFrom: Joerg Vehlow <[email protected]>
The buffer used in the sprintf was too small and could overflow.
--- .../open_posix_testsuite/conformance/interfaces/asctime/1-1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/open_posix_testsuite/conformance/interfaces/asctime/1-1.c +1 -1
@@ -28,7 +28,7 @@ int main(void) {struct tm time_ptr; -char expected[26 ]; +char expected[128 ];char *real; char wday_name[7][3] =
Signature · 5 lines
2.25.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 08/12] posix/asctime: Fix potentioal buffer overflow
Hi!
Pushed, thanks.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 9/12 posix/conformance/interfaces/pthread_*_destroy: Suppress nonnull warning
In reply to Joerg VehlowFrom: Joerg Vehlow <[email protected]>
These two tests are specifically testing passing NULL to the functions, so we supress the error message at least for gcc.
--- .../conformance/interfaces/pthread_condattr_destroy/4-1.c | 3 +++ .../conformance/interfaces/pthread_mutexattr_destroy/4-1.c | 3 +++ 2 files changed, 6 insertions(+)
testcases/open_posix_testsuite/conformance/interfaces/pthread_condattr_destroy/4-1.c +3 -0
@@ -15,6 +15,9 @@* */ +/* This test explicitly tries to pass null to a parameter, that should not be NULL */ +#pragma GCC diagnostic ignored "-Wnonnull" +#include <pthread.h> #include <stdio.h> #include <errno.h>
testcases/open_posix_testsuite/conformance/interfaces/pthread_mutexattr_destroy/4-1.c +3 -0
@@ -15,6 +15,9 @@* */ +/* This test explicitly tries to pass null to a parameter, that should not be NULL */ +#pragma GCC diagnostic ignored "-Wnonnull" +#include <pthread.h> #include <stdio.h> #include <errno.h>
Signature · 5 lines
2.25.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 09/12] posix/conformance/interfaces/pthread_*_destroy: Suppress nonnull warning
Hi!
Applied, thanks.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 10/12 posix/conformance/interfaces: Fix all sign-compare warnings
In reply to Joerg VehlowFrom: Joerg Vehlow <[email protected]>
--- .../conformance/interfaces/pthread_exit/1-2.c | 2 +- .../conformance/interfaces/pthread_exit/2-2.c | 3 ++- .../conformance/interfaces/pthread_exit/3-2.c | 3 ++- .../conformance/interfaces/pthread_exit/4-1.c | 2 +- .../conformance/interfaces/pthread_exit/5-1.c | 3 ++- .../conformance/interfaces/pthread_mutex_trylock/1-2.c | 2 +- .../conformance/interfaces/pthread_mutex_trylock/2-1.c | 2 +- .../conformance/interfaces/pthread_sigmask/18-1.c | 2 +- .../conformance/interfaces/pthread_sigmask/7-1.c | 3 ++- 9 files changed, 13 insertions(+), 9 deletions(-)
testcases/open_posix_testsuite/conformance/interfaces/pthread_exit/1-2.c +1 -1
@@ -105,7 +105,7 @@ int main(void)int ret =0 ;void *rval;pthread_t child; -int i; +unsigned int i;output_init ();
testcases/open_posix_testsuite/conformance/interfaces/pthread_exit/2-2.c +2 -1
@@ -123,7 +123,8 @@ int main(void)int ret =0 ;void *rval;pthread_t child; -int i, j; +unsigned int i; +int j;output_init ();
testcases/open_posix_testsuite/conformance/interfaces/pthread_exit/3-2.c +2 -1
@@ -149,7 +149,8 @@ int main(void)int ret =0 ;void *rval;pthread_t child; -int i, j; +unsigned int i; +int j;output_init ();
testcases/open_posix_testsuite/conformance/interfaces/pthread_exit/4-1.c +1 -1
@@ -122,7 +122,7 @@ int main(void)int ret =0 ;void *rval;pthread_t child; -int i; +unsigned int i;output_init ();
testcases/open_posix_testsuite/conformance/interfaces/pthread_exit/5-1.c +2 -1
@@ -141,7 +141,8 @@ int main(void)int ctl =0 ;void *rval;pthread_t child; -int i, j; +unsigned int i; +int j;output_init ();
testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_trylock/1-2.c +1 -1
@@ -149,7 +149,7 @@ static void *tf(void *arg)int main (void ) {int ret; -int sc; +unsigned int sc;pthread_mutexattr_t ma;testdata_t *td;
testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_trylock/2-1.c +1 -1
@@ -126,7 +126,7 @@ static void *tf(void *arg)int main (void ) {int ret; -int sc; +unsigned int sc;pthread_mutexattr_t ma;testdata_t *td;
testcases/open_posix_testsuite/conformance/interfaces/pthread_sigmask/18-1.c +1 -1
@@ -158,7 +158,7 @@ static void *test(void *arg PTS_ATTRIBUTE_UNUSED) {int ret =0 ;sigset_t set; -int i, j =0 ; +unsigned int i, j =0 ;int signals[] = {SIGBUS ,SIGKILL ,SIGABRT ,SIGCHLD ,SIGHUP };#define NSIG (sizeof(signals)/sizeof(int))int operation[] = {SIG_SETMASK ,SIG_BLOCK ,SIG_UNBLOCK };
testcases/open_posix_testsuite/conformance/interfaces/pthread_sigmask/7-1.c +2 -1
@@ -24,7 +24,8 @@ returned by the pthread_sigmask functions.static void *a_thread_func () {sigset_t oactl, tempset; -int i, j, test_failed =0 ; +unsigned int i, j; +int test_failed =0 ;int siglist[] = {SIGABRT ,SIGALRM ,SIGBUS ,SIGCHLD ,SIGCONT ,SIGFPE ,SIGHUP ,SIGILL ,SIGINT ,
Signature · 5 lines
2.25.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 10/12] posix/conformance/interfaces: Fix all sign-compare warnings
Hi!
Applied, thanks.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 11/12 posix/conformance/interface/mmap/5-1: Remove invalid static
In reply to Joerg VehlowFrom: Joerg Vehlow <[email protected]>
A storage class specifier for a struct definition has no effect
--- .../open_posix_testsuite/conformance/interfaces/mmap/5-1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/open_posix_testsuite/conformance/interfaces/mmap/5-1.c +1 -1
@@ -34,7 +34,7 @@#include "posixtest.h" #include "tempfile.h" -static struct testcase { +struct testcase {int prot;int flags; };
Signature · 5 lines
2.25.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 11/12] posix/conformance/interface/mmap/5-1: Remove invalid static
Hi!
Applied, thanks.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 12/12 posix/interface/conformance: Fix/supress all unused-result warnings
In reply to Joerg VehlowFrom: Joerg Vehlow <[email protected]>
The warnings for writes in signalhandlers can only be suppressed, there is no good way to handle an error there. In all other locations a failing function is printed and PTS_UNRESOLVED returned.
--- .../conformance/interfaces/clock_getcpuclockid/5-1.c | 10 ++++++++-- .../conformance/interfaces/fork/7-1.c | 3 ++- .../conformance/interfaces/kill/2-2.c | 5 ++++- .../conformance/interfaces/kill/3-1.c | 5 ++++- .../conformance/interfaces/mmap/11-2.c | 5 +++++ .../conformance/interfaces/mmap/11-3.c | 5 +++++ .../conformance/interfaces/mmap/18-1.c | 6 +++++- .../conformance/interfaces/mq_open/16-1.c | 8 ++++++-- .../conformance/interfaces/pthread_create/1-3.c | 11 +++++++++-- .../conformance/interfaces/sched_setparam/2-1.c | 5 ++++- .../conformance/interfaces/sched_setparam/2-2.c | 5 ++++- .../conformance/interfaces/sched_yield/1-1.c | 9 ++++++--- .../conformance/interfaces/shm_open/26-2.c | 9 ++++++--- .../conformance/interfaces/shm_unlink/8-1.c | 3 ++- .../conformance/interfaces/shm_unlink/9-1.c | 6 ++++-- .../conformance/interfaces/sigaction/19-1.c | 9 +++++++-- .../conformance/interfaces/sigaction/19-10.c | 9 +++++++-- .../conformance/interfaces/sigaction/19-11.c | 9 +++++++-- .../conformance/interfaces/sigaction/19-12.c | 9 +++++++-- .../conformance/interfaces/sigaction/19-13.c | 9 +++++++-- .../conformance/interfaces/sigaction/19-14.c | 9 +++++++-- .../conformance/interfaces/sigaction/19-15.c | 9 +++++++-- .../conformance/interfaces/sigaction/19-16.c | 9 +++++++-- .../conformance/interfaces/sigaction/19-17.c | 9 +++++++-- .../conformance/interfaces/sigaction/19-18.c | 9 +++++++-- .../conformance/interfaces/sigaction/19-19.c | 9 +++++++-- .../conformance/interfaces/sigaction/19-2.c | 9 +++++++-- .../conformance/interfaces/sigaction/19-20.c | 9 +++++++-- .../conformance/interfaces/sigaction/19-21.c | 9 +++++++-- .../conformance/interfaces/sigaction/19-22.c | 8 ++++++-- .../conformance/interfaces/sigaction/19-23.c | 9 +++++++-- .../conformance/interfaces/sigaction/19-24.c | 9 +++++++-- .../conformance/interfaces/sigaction/19-25.c | 9 +++++++-- .../conformance/interfaces/sigaction/19-26.c | 9 +++++++-- .../conformance/interfaces/sigaction/19-3.c | 9 +++++++-- .../conformance/interfaces/sigaction/19-4.c | 9 +++++++-- .../conformance/interfaces/sigaction/19-5.c | 9 +++++++-- .../conformance/interfaces/sigaction/19-6.c | 9 +++++++-- .../conformance/interfaces/sigaction/19-7.c | 9 +++++++-- .../conformance/interfaces/sigaction/19-8.c | 9 +++++++-- .../conformance/interfaces/sigaction/19-9.c | 9 +++++++-- .../conformance/interfaces/sigaltstack/9-1.c | 5 ++++- testcases/open_posix_testsuite/include/affinity.h | 3 ++- 43 files changed, 261 insertions(+), 75 deletions(-)
testcases/open_posix_testsuite/conformance/interfaces/clock_getcpuclockid/5-1.c +8 -2
@@ -35,8 +35,14 @@ int main(void) pwd =getpwnam ("nobody" );if (pwd !=NULL ) { -setgid (pwd->pw_gid); -setuid (pwd->pw_uid); +if (setgid (pwd->pw_gid)) { +perror ("setgid" ); +return PTS_UNRESOLVED ; + } +if (setuid (pwd->pw_uid)) { +perror ("setuid" ); +return PTS_UNRESOLVED ; + } } }
testcases/open_posix_testsuite/conformance/interfaces/fork/7-1.c +2 -1
@@ -157,7 +157,8 @@ int main(void)if (ret !=0 )UNRESOLVED (errno,"Failed to close the message catalog" ); -system ("rm -f " MESSCAT_IN " " MESSCAT_OUT ); +unlink (MESSCAT_IN ); +unlink (MESSCAT_OUT );#if VERBOSE >0 output ("Test passed\n" );
testcases/open_posix_testsuite/conformance/interfaces/kill/2-2.c +4 -1
@@ -55,7 +55,10 @@ int main(void)*/ /* this is added incase user is root. If user is normal user, then it * has no effect on the tests */ -setuid (1 ); +if (setuid (1 )) { +perror ("setuid" ); +return PTS_UNRESOLVED ; + }if (-1 ==kill (1 ,0 )) {if (EPERM == errno) {
testcases/open_posix_testsuite/conformance/interfaces/kill/3-1.c +4 -1
@@ -23,7 +23,10 @@ int main(void) {/* this is added incase user is root. If user is normal user, then it * has no effect on the tests */ -setuid (1 ); +if (setuid (1 )) { +perror ("setuid" ); +return PTS_UNRESOLVED ; + }if (kill (1 ,0 ) !=-1 ) { printf
testcases/open_posix_testsuite/conformance/interfaces/mmap/11-2.c +5 -0
@@ -33,6 +33,9 @@#include "posixtest.h" #include "tempfile.h" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" +#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1)static void sigbus_handler (int signum)
@@ -44,6 +47,8 @@ static void sigbus_handler(int signum) } } +#pragma GCC diagnostic pop +int main (void ) {#ifndef _POSIX_MEMORY_PROTECTION
testcases/open_posix_testsuite/conformance/interfaces/mmap/11-3.c +5 -0
@@ -31,6 +31,9 @@#include <unistd.h> #include "posixtest.h" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" +#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1)static void sigbus_handler (int signum)
@@ -42,6 +45,8 @@ static void sigbus_handler(int signum) } } +#pragma GCC diagnostic pop +int main (void ) {#ifndef _POSIX_MEMORY_PROTECTION
testcases/open_posix_testsuite/conformance/interfaces/mmap/18-1.c +5 -1
@@ -131,7 +131,11 @@ int main(void)printf ("Got EAGAIN: %s\n" ,strerror (errno));printf ("Test PASSED\n" );/* Change user to root */ -seteuid (0 ); +if (seteuid (0 )) { +close (fd); +perror ("seteuid" ); +return PTS_UNRESOLVED ; + }close (fd);munmap (pa, len);return PTS_PASS ;
testcases/open_posix_testsuite/conformance/interfaces/mq_open/16-1.c +6 -2
@@ -61,10 +61,14 @@ int main(void)printf (TNAME " Error at open(): %s\n" ,strerror (errno));return PTS_UNRESOLVED ; } -/* file is empty now, will cause "Bus error" */ -write (fd, fname,sizeof (int ));unlink (fname); +if (ftruncate (fd,sizeof (int ))) { +perror ("ftruncate" ); +close (fd); +return PTS_UNRESOLVED ; + } + pa =mmap (NULL ,sizeof (int ),PROT_READ |PROT_WRITE ,MAP_SHARED , fd,0 );if (pa ==MAP_FAILED ) {printf (TNAME " Error at mmap: %s\n" ,strerror (errno));
testcases/open_posix_testsuite/conformance/interfaces/pthread_create/1-3.c +9 -2
@@ -10,8 +10,8 @@* * Steps: * 1. Create a new thread that will go into a never-ending while loop. -* 2. If the thread is truly asynchronise, then the main function will -* continue instead of waiting for the thread to return (which in never +* 2. If the thread is truly asynchronous, then the main function will +* continue instead of waiting for the thread to return (which it never * does in this test case). * 3. An alarm is set to go off (i.e. send the SIGARLM signal) after 3 * seconds. This is done for 'timeing-out' reasons, in case main DOES
@@ -30,6 +30,8 @@static void *a_thread_function ();static void alarm_handler (); +static volatile int alarm_triggered; +static pthread_t a;int main (void )
@@ -72,6 +74,9 @@ static void *a_thread_function()return NULL ; } +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" +#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1)/* If this handler is called, that means that the test has failed. */
@@ -80,3 +85,5 @@ static void alarm_handler()WRITE ("Test FAILED: Alarm fired while waiting for cancelation\n" );_exit (PTS_FAIL ); } + +#pragma GCC diagnostic pop
testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/2-1.c +4 -1
@@ -125,7 +125,10 @@ int main(void)return PTS_UNRESOLVED ; } -pipe (the_pipe); +if (pipe (the_pipe)) { +perror ("pipe" ); +return PTS_UNRESOLVED ; + }for (i =0 ; i < nb_child; i++) { child_pid[i] =fork ();
testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/2-2.c +4 -1
@@ -129,7 +129,10 @@ int main(void)return PTS_UNRESOLVED ; } -pipe (the_pipe); +if (pipe (the_pipe)) { +perror ("pipe" ); +return PTS_UNRESOLVED ; + }for (i =0 ; i < nb_child; i++) { child_pid[i] =fork ();
testcases/open_posix_testsuite/conformance/interfaces/sched_yield/1-1.c +6 -3
@@ -45,18 +45,21 @@ static int child_busy(int fd)alarm (4 );/* Tell the parent we're ready */ -write (fd,"go" ,2 ); +if (write (fd,"go" ,2 ) ==-1 ) { +perror ("write" ); +exit (PTS_UNRESOLVED ); + }for (;;) { rc =sched_yield ();if (rc) {ERR_LOG ("child: sched_yield" , rc); -exit (1 ); +exit (PTS_FAIL ); } }/* should not get here */ -exit (2 ); +exit (PTS_UNRESOLVED ); }int main (void )
testcases/open_posix_testsuite/conformance/interfaces/shm_open/26-2.c +6 -3
@@ -95,19 +95,22 @@ int main(void) fd =shm_open (SHM_NAME ,O_RDWR |O_TRUNC ,0 );if (fd ==-1 ) {perror ("An error occurs when calling shm_open()" ); -seteuid (getuid ()); +if (seteuid (getuid ())) +perror ("seteuid" );shm_unlink (SHM_NAME );return PTS_UNRESOLVED ; }if (fstat (fd, &stat_buf) !=0 ) {perror ("An error occurs when calling fstat()" ); -seteuid (getuid ()); +if (seteuid (getuid ())) +perror ("seteuid" );shm_unlink (SHM_NAME );return PTS_UNRESOLVED ; } -seteuid (getuid ()); +if (seteuid (getuid ())) +perror ("seteuid" );shm_unlink (SHM_NAME );if (stat_buf.st_uid == old_uid && stat_buf.st_gid == old_gid) {
testcases/open_posix_testsuite/conformance/interfaces/shm_unlink/8-1.c +2 -1
@@ -86,7 +86,8 @@ int main(void)return PTS_UNRESOLVED ; } -seteuid (getuid ()); +if (seteuid (getuid ())) +perror ("seteuid" );if (fstat (fd, &stat_after) !=0 ) {perror ("An error occurs when calling fstat()" );
testcases/open_posix_testsuite/conformance/interfaces/shm_unlink/9-1.c +4 -2
@@ -69,12 +69,14 @@ int main(void) result =shm_unlink (SHM_NAME );if (result ==-1 && errno ==EACCES ) {printf ("Test PASSED\n" ); -seteuid (getuid ()); +if (seteuid (getuid ())) +perror ("seteuid" );shm_unlink (SHM_NAME );return PTS_PASS ; }else if (result ==-1 ) {perror ("Unexpected error" ); -seteuid (getuid ()); +if (seteuid (getuid ())) +perror ("seteuid" );shm_unlink (SHM_NAME );return PTS_FAIL ; }
testcases/open_posix_testsuite/conformance/interfaces/sigaction/19-1.c +7 -2
@@ -40,10 +40,13 @@#include <errno.h> #include "posixtest.h" -#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) -static volatile sig_atomic_t called =0 ; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" + +#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) +static void handler (int sig,siginfo_t *info,void *context) { (void ) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context) called =1 ; } +#pragma GCC diagnostic pop +int main (void ) {int ret;
testcases/open_posix_testsuite/conformance/interfaces/sigaction/19-10.c +7 -2
@@ -40,10 +40,13 @@#include <errno.h> #include "posixtest.h" -#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) -static volatile sig_atomic_t called =0 ; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" + +#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) +static void handler (int sig,siginfo_t *info,void *context) { (void ) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context) called =1 ; } +#pragma GCC diagnostic pop +int main (void ) {int ret;
testcases/open_posix_testsuite/conformance/interfaces/sigaction/19-11.c +7 -2
@@ -40,10 +40,13 @@#include <errno.h> #include "posixtest.h" -#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) -static volatile sig_atomic_t called =0 ; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" + +#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) +static void handler (int sig,siginfo_t *info,void *context) { (void ) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context) called =1 ; } +#pragma GCC diagnostic pop +int main (void ) {int ret;
testcases/open_posix_testsuite/conformance/interfaces/sigaction/19-12.c +7 -2
@@ -40,10 +40,13 @@#include <errno.h> #include "posixtest.h" -#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) -static volatile sig_atomic_t called =0 ; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" + +#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) +static void handler (int sig,siginfo_t *info,void *context) { (void ) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context) called =1 ; } +#pragma GCC diagnostic pop +int main (void ) {int ret;
testcases/open_posix_testsuite/conformance/interfaces/sigaction/19-13.c +7 -2
@@ -40,10 +40,13 @@#include <errno.h> #include "posixtest.h" -#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) -static volatile sig_atomic_t called =0 ; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" + +#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) +static void handler (int sig,siginfo_t *info,void *context) { (void ) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context) called =1 ; } +#pragma GCC diagnostic pop +int main (void ) {int ret;
testcases/open_posix_testsuite/conformance/interfaces/sigaction/19-14.c +7 -2
@@ -40,10 +40,13 @@#include <errno.h> #include "posixtest.h" -#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) -static volatile sig_atomic_t called =0 ; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" + +#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) +static void handler (int sig,siginfo_t *info,void *context) { (void ) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context) called =1 ; } +#pragma GCC diagnostic pop +int main (void ) {int ret;
testcases/open_posix_testsuite/conformance/interfaces/sigaction/19-15.c +7 -2
@@ -40,10 +40,13 @@#include <errno.h> #include "posixtest.h" -#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) -static volatile sig_atomic_t called =0 ; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" + +#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) +static void handler (int sig,siginfo_t *info,void *context) { (void ) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context) called =1 ; } +#pragma GCC diagnostic pop +int main (void ) {int ret;
testcases/open_posix_testsuite/conformance/interfaces/sigaction/19-16.c +7 -2
@@ -40,10 +40,13 @@#include <errno.h> #include "posixtest.h" -#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) -static volatile sig_atomic_t called =0 ; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" + +#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) +static void handler (int sig,siginfo_t *info,void *context) { (void ) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context) called =1 ; } +#pragma GCC diagnostic pop +int main (void ) {int ret;
testcases/open_posix_testsuite/conformance/interfaces/sigaction/19-17.c +7 -2
@@ -40,10 +40,13 @@#include <errno.h> #include "posixtest.h" -#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) -static volatile sig_atomic_t called =0 ; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" + +#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) +static void handler (int sig,siginfo_t *info,void *context) { (void ) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context) called =1 ; } +#pragma GCC diagnostic pop +int main (void ) {int ret;
testcases/open_posix_testsuite/conformance/interfaces/sigaction/19-18.c +7 -2
@@ -40,10 +40,13 @@#include <errno.h> #include "posixtest.h" -#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) -static volatile sig_atomic_t called =0 ; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" + +#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) +static void handler (int sig,siginfo_t *info,void *context) { (void ) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context) called =1 ; } +#pragma GCC diagnostic pop +int main (void ) {int ret;
testcases/open_posix_testsuite/conformance/interfaces/sigaction/19-19.c +7 -2
@@ -40,10 +40,13 @@#include <errno.h> #include "posixtest.h" -#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) -static volatile sig_atomic_t called =0 ; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" + +#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) +static void handler (int sig,siginfo_t *info,void *context) { (void ) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context) called =1 ; } +#pragma GCC diagnostic pop +int main (void ) {int ret;
testcases/open_posix_testsuite/conformance/interfaces/sigaction/19-2.c +7 -2
@@ -40,10 +40,13 @@#include <errno.h> #include "posixtest.h" -#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) -static volatile sig_atomic_t called =0 ; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" + +#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) +static void handler (int sig,siginfo_t *info,void *context) { (void ) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context) called =1 ; } +#pragma GCC diagnostic pop +int main (void ) {int ret;
testcases/open_posix_testsuite/conformance/interfaces/sigaction/19-20.c +7 -2
@@ -40,10 +40,13 @@#include <errno.h> #include "posixtest.h" -#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) -static volatile sig_atomic_t called =0 ; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" + +#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) +static void handler (int sig,siginfo_t *info,void *context) { (void ) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context) called =1 ; } +#pragma GCC diagnostic pop +int main (void ) {int ret;
testcases/open_posix_testsuite/conformance/interfaces/sigaction/19-21.c +7 -2
@@ -40,10 +40,13 @@#include <errno.h> #include "posixtest.h" -#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) -static volatile sig_atomic_t called =0 ; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" + +#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) +static void handler (int sig,siginfo_t *info,void *context) { (void ) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context) called =1 ; } +#pragma GCC diagnostic pop +int main (void ) {int ret;
testcases/open_posix_testsuite/conformance/interfaces/sigaction/19-22.c +6 -2
@@ -39,10 +39,12 @@#include <signal.h> #include <errno.h> #include "posixtest.h" +static volatile sig_atomic_t called =0 ; -#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" -static volatile sig_atomic_t called =0 ; +#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1)static void handler (int sig,siginfo_t *info,void *context) {
@@ -57,6 +59,8 @@ static void handler(int sig, siginfo_t *info, void *context) called =1 ; } +#pragma GCC diagnostic pop +int main (void ) {int ret;
testcases/open_posix_testsuite/conformance/interfaces/sigaction/19-23.c +7 -2
@@ -40,10 +40,13 @@#include <errno.h> #include "posixtest.h" -#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) -static volatile sig_atomic_t called =0 ; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" + +#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) +static void handler (int sig,siginfo_t *info,void *context) { (void ) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context) called =1 ; } +#pragma GCC diagnostic pop +int main (void ) {int ret;
testcases/open_posix_testsuite/conformance/interfaces/sigaction/19-24.c +7 -2
@@ -40,10 +40,13 @@#include <errno.h> #include "posixtest.h" -#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) -static volatile sig_atomic_t called =0 ; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" + +#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) +static void handler (int sig,siginfo_t *info,void *context) { (void ) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context) called =1 ; } +#pragma GCC diagnostic pop +int main (void ) {int ret;
testcases/open_posix_testsuite/conformance/interfaces/sigaction/19-25.c +7 -2
@@ -40,10 +40,13 @@#include <errno.h> #include "posixtest.h" -#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) -static volatile sig_atomic_t called =0 ; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" + +#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) +static void handler (int sig,siginfo_t *info,void *context) { (void ) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context) called =1 ; } +#pragma GCC diagnostic pop +int main (void ) {int ret;
testcases/open_posix_testsuite/conformance/interfaces/sigaction/19-26.c +7 -2
@@ -40,10 +40,13 @@#include <errno.h> #include "posixtest.h" -#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) -static volatile sig_atomic_t called =0 ; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" + +#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) +static void handler (int sig,siginfo_t *info,void *context) { (void ) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context) called =1 ; } +#pragma GCC diagnostic pop +int main (void ) {int ret;
testcases/open_posix_testsuite/conformance/interfaces/sigaction/19-3.c +7 -2
@@ -40,10 +40,13 @@#include <errno.h> #include "posixtest.h" -#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) -static volatile sig_atomic_t called =0 ; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" + +#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) +static void handler (int sig,siginfo_t *info,void *context) { (void ) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context) called =1 ; } +#pragma GCC diagnostic pop +int main (void ) {int ret;
testcases/open_posix_testsuite/conformance/interfaces/sigaction/19-4.c +7 -2
@@ -40,10 +40,13 @@#include <errno.h> #include "posixtest.h" -#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) -static volatile sig_atomic_t called =0 ; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" + +#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) +static void handler (int sig,siginfo_t *info,void *context) { (void ) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context) called =1 ; } +#pragma GCC diagnostic pop +int main (void ) {int ret;
testcases/open_posix_testsuite/conformance/interfaces/sigaction/19-5.c +7 -2
@@ -40,10 +40,13 @@#include <errno.h> #include "posixtest.h" -#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) -static volatile sig_atomic_t called =0 ; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" + +#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) +static void handler (int sig,siginfo_t *info,void *context) { (void ) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context) called =1 ; } +#pragma GCC diagnostic pop +int main (void ) {int ret;
testcases/open_posix_testsuite/conformance/interfaces/sigaction/19-6.c +7 -2
@@ -40,10 +40,13 @@#include <errno.h> #include "posixtest.h" -#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) -static volatile sig_atomic_t called =0 ; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" + +#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) +static void handler (int sig,siginfo_t *info,void *context) { (void ) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context) called =1 ; } +#pragma GCC diagnostic pop +int main (void ) {int ret;
testcases/open_posix_testsuite/conformance/interfaces/sigaction/19-7.c +7 -2
@@ -40,10 +40,13 @@#include <errno.h> #include "posixtest.h" -#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) -static volatile sig_atomic_t called =0 ; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" + +#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) +static void handler (int sig,siginfo_t *info,void *context) { (void ) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context) called =1 ; } +#pragma GCC diagnostic pop +int main (void ) {int ret;
testcases/open_posix_testsuite/conformance/interfaces/sigaction/19-8.c +7 -2
@@ -40,10 +40,13 @@#include <errno.h> #include "posixtest.h" -#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) -static volatile sig_atomic_t called =0 ; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" + +#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) +static void handler (int sig,siginfo_t *info,void *context) { (void ) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context) called =1 ; } +#pragma GCC diagnostic pop +int main (void ) {int ret;
testcases/open_posix_testsuite/conformance/interfaces/sigaction/19-9.c +7 -2
@@ -40,10 +40,13 @@#include <errno.h> #include "posixtest.h" -#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) -static volatile sig_atomic_t called =0 ; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result" + +#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1) +static void handler (int sig,siginfo_t *info,void *context) { (void ) sig;
@@ -57,6 +60,8 @@ static void handler(int sig, siginfo_t *info, void *context) called =1 ; } +#pragma GCC diagnostic pop +int main (void ) {int ret;
testcases/open_posix_testsuite/conformance/interfaces/sigaltstack/9-1.c +4 -1
@@ -59,7 +59,10 @@ int main(int argc, char *argv[])/* Get abs path if needed and exec ourself */ if (*argv[0 ] !='/' ) { -getcwd (path,PATH_MAX ); +if (getcwd (path,PATH_MAX ) ==NULL ) { +perror ("getcwd" ); +exit (PTS_UNRESOLVED ); + }strcat (path,"/" );strcat (path, argv[0 ]); }else {
testcases/open_posix_testsuite/include/affinity.h +2 -1
@@ -46,7 +46,8 @@ static int get_online_cpu_from_sysfs(void) f =fopen ("/sys/devices/system/cpu/online" ,"r" );if (!f)return -1 ; -fscanf (f,"%d" , &cpu); +if (!fscanf (f,"%d" , &cpu)) + cpu =-1 ;fclose (f);return cpu;
Signature · 5 lines
2.25.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 12/12] posix/interface/conformance: Fix/supress all unused-result warnings
Hi!
testcases/open_posix_testsuite/conformance/interfaces/mmap/11-2.c line 39
Quoted 10 lines
testcases/open_posix_testsuite/conformance/interfaces/mmap/11-2.c +2
-0@@ -33,6 +33,9 @@#include "posixtest.h" #include "tempfile.h" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result"#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1)
There is actually better trick than disabling the warning with pragmas, we use it in lib/tst_test.c as well:
#define WRITE_MSG(msg) do { \
if (write(STDOUT_FILENO, msg, sizeof(msg) - 1)) { \
/* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425 */ \
} \
} while (0)I guess that we should add PTS_WRITE_MSG() to the posixtest.h and make use of it in all open posix tests.
The rest of the patch looks good.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 12/12] posix/interface/conformance: Fix/supress all unused-result warnings
Hi Cyril,
Quoted 20 lines
Hi!
testcases/open_posix_testsuite/conformance/interfaces/mmap/11-2.c line 39
Quoted 10 lines
testcases/open_posix_testsuite/conformance/interfaces/mmap/11-2.c +2
-0@@ -33,6 +33,9 @@#include "posixtest.h" #include "tempfile.h" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-result"#define WRITE (str) write(STDOUT_FILENO, str, sizeof(str) - 1)There is actually better trick than disabling the warning with pragmas, we use it in
lib/tst_test.cas well:#define WRITE_MSG(msg) do { \ if (write(STDOUT_FILENO, msg, sizeof(msg) - 1)) { \ /* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425 */ \ } \ } while (0)
Quoted 4 lines
I guess that we should add
PTS_WRITE_MSG()to theposixtest.hand make use of it in all open posix tests.The rest of the patch looks good.
Ok I'll fix it like that. I also like one macro in posixtest.h better than in every file.
Joerg
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp