openposix: Fix 'no return in nonvoid function' warnings
cover openposix: Fix 'no return in nonvoid function' warnings
Fixes LTP compilation in build systems where the 'no return in nonvoid function' warning is treated as error. More than half of the cases were actually a buggy tests, which only shows that maybe treating this warning as an error makes sense.
Cyril Hrubis (7):
openposix: pthread_rwlockattr_getpshared/2-1: Fix
openposix: pthread_spin_init/{2-1,2-2}: Fix
openposix: sem_destroy/3-1: Fix
openposix: sem_timedwait/11-1: Fix
openposix: aio_h/2-1: Add return at the end of main()
openposix: mq_timedreceive: Silence warning
opeposix: pthread_barrierattr_getpshared/2-1: Simplify codeflow
.../conformance/definitions/aio_h/2-1.c | 2 ++ .../interfaces/mq_timedreceive/5-3.c | 1 + .../pthread_barrierattr_getpshared/2-1.c | 11 +++---- .../pthread_rwlockattr_getpshared/2-1.c | 20 ++++++++++-- .../interfaces/pthread_spin_init/2-1.c | 20 ++++++++++-- .../interfaces/pthread_spin_init/2-2.c | 20 ++++++++++-- .../conformance/interfaces/sem_destroy/3-1.c | 31 +++++++++++++------ .../interfaces/sem_timedwait/11-1.c | 9 +++--- 8 files changed, 89 insertions(+), 25 deletions(-)
Signature · 5 lines
2.35.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 1/7 openposix: pthread_rwlockattr_getpshared/2-1: Fix
Propagate a failure in child to the parent properly.
--- .../pthread_rwlockattr_getpshared/2-1.c | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlockattr_getpshared/2-1.c +18 -2
@@ -126,7 +126,11 @@ int main(void)if (pid ==-1 ) {perror ("Error at fork()" );return PTS_UNRESOLVED ; - }else if (pid >0 ) { + } + +if (pid >0 ) { +int status; +/* Parent */ /* wait until child do wrlock */ while (rwlock_data->data ==0 ) {
@@ -141,7 +145,7 @@ int main(void)printf ("Parent unlocked.\n" );/* Wait for child to end */ -wait (NULL ); +wait (&status);if ((shm_unlink (shm_name)) !=0 ) {perror ("Error at shm_unlink()" );
@@ -154,6 +158,16 @@ int main(void)return PTS_FAIL ; } +if (!WIFEXITED (status)) { +printf ("Parent: did not exit properly!\n" ); +return PTS_FAIL ; + } + +if (WEXITSTATUS (status)) { +printf ("Parent: failure in child\n" ); +return WEXITSTATUS (status); + } +printf ("Test PASSED\n" );return PTS_PASS ; }else {
@@ -195,5 +209,7 @@ int main(void) rwlock_data->data =-1 ;return PTS_FAIL ; } + +return PTS_PASS ; } }
Signature · 5 lines
2.35.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 1/7] openposix: pthread_rwlockattr_getpshared/2-1: Fix
Hello,
Quoted 60 lines · Cyril Hrubis
Propagate a failure in child to the parent properly.
Signed-off-by Cyril Hrubis <[email protected]>--- .../pthread_rwlockattr_getpshared/2-1.c | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlockattr_getpshared/2-1.c +18
-2@@ -126,7 +126,11 @@ int main(void)if (pid ==-1 ) {perror ("Error at fork()" );return PTS_UNRESOLVED ; - }else if (pid >0 ) { + } + +if (pid >0 ) { +int status; +/* Parent */ /* wait until child do wrlock */ while (rwlock_data->data ==0 ) {@@ -141,7 +145,7 @@ int main(void)printf ("Parent unlocked.\n" );/* Wait for child to end */ -wait (NULL ); +wait (&status);if ((shm_unlink (shm_name)) !=0 ) {perror ("Error at shm_unlink()" );@@ -154,6 +158,16 @@ int main(void)return PTS_FAIL ; } +if (!WIFEXITED (status)) { +printf ("Parent: did not exit properly!\n" ); +return PTS_FAIL ; + } + +if (WEXITSTATUS (status)) { +printf ("Parent: failure in child\n" ); +return WEXITSTATUS (status); + } +printf ("Test PASSED\n" );return PTS_PASS ; }else {@@ -195,5 +209,7 @@ int main(void) rwlock_data->data =-1 ;return PTS_FAIL ; } + +return PTS_PASS ; } }Signature · 1 line
2.35.1
Signature · 5 lines
Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 2/7 openposix: pthread_spin_init/{2-1,2-2}: Fix
In reply to Cyril HrubisPropagate a failure in child to the parent properly.
--- .../interfaces/pthread_spin_init/2-1.c | 20 +++++++++++++++++-- .../interfaces/pthread_spin_init/2-2.c | 20 +++++++++++++++++-- 2 files changed, 36 insertions(+), 4 deletions(-)
testcases/open_posix_testsuite/conformance/interfaces/pthread_spin_init/2-1.c +18 -2
@@ -100,7 +100,11 @@ int main(void)if (pid ==-1 ) {perror ("Error at fork()" );return PTS_UNRESOLVED ; - }else if (pid >0 ) { + } + +if (pid >0 ) { +int status; +/* Parent */ /* wait until child writes to spinlock data */ while (spinlock_data->data !=1 )
@@ -116,13 +120,23 @@ int main(void) spinlock_data->data =2 ;/* Wait until child ends */ -wait (NULL ); +wait (&status);if ((shm_unlink (shm_name)) !=0 ) {perror ("Error at shm_unlink()" );return PTS_UNRESOLVED ; } +if (!WIFEXITED (status)) { +printf ("Parent: did not exit properly!\n" ); +return PTS_FAIL ; + } + +if (WEXITSTATUS (status)) { +printf ("Parent: failure in child\n" ); +return WEXITSTATUS (status); + } +printf ("Test PASSED\n" );return PTS_PASS ; }else {
@@ -170,5 +184,7 @@ int main(void)printf ("Child: error at pthread_spin_destroy()\n" );return PTS_UNRESOLVED ; } + +return PTS_PASS ; } }
testcases/open_posix_testsuite/conformance/interfaces/pthread_spin_init/2-2.c +18 -2
@@ -106,7 +106,11 @@ int main(void)if (pid ==-1 ) {perror ("Error at fork()" );return PTS_UNRESOLVED ; - }else if (pid >0 ) { + } + +if (pid >0 ) { +int status; +/* Parent */ /* wait until child writes to spinlock data */ while (spinlock_data->data !=1 )
@@ -122,13 +126,23 @@ int main(void) spinlock_data->data =2 ;/* Wait until child ends */ -wait (NULL ); +wait (&status);if ((shm_unlink (shm_name)) !=0 ) {perror ("Error at shm_unlink()" );return PTS_UNRESOLVED ; } +if (!WIFEXITED (status)) { +printf ("Parent: did not exit properly!\n" ); +return PTS_FAIL ; + } + +if (WEXITSTATUS (status)) { +printf ("Parent: failure in child\n" ); +return WEXITSTATUS (status); + } +printf ("Test PASSED\n" );return PTS_PASS ; }else {
@@ -175,5 +189,7 @@ int main(void)printf ("Child: error at pthread_spin_destroy()\n" );return PTS_UNRESOLVED ; } + +return PTS_PASS ; } }
Signature · 5 lines
2.35.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 2/7] openposix: pthread_spin_init/{2-1,2-2}: Fix
Hello,
Quoted 110 lines · Cyril Hrubis
Propagate a failure in child to the parent properly.
Signed-off-by Cyril Hrubis <[email protected]>--- .../interfaces/pthread_spin_init/2-1.c | 20 +++++++++++++++++-- .../interfaces/pthread_spin_init/2-2.c | 20 +++++++++++++++++-- 2 files changed, 36 insertions(+), 4 deletions(-)testcases/open_posix_testsuite/conformance/interfaces/pthread_spin_init/2-1.c +18
-2@@ -100,7 +100,11 @@ int main(void)if (pid ==-1 ) {perror ("Error at fork()" );return PTS_UNRESOLVED ; - }else if (pid >0 ) { + } + +if (pid >0 ) { +int status; +/* Parent */ /* wait until child writes to spinlock data */ while (spinlock_data->data !=1 )@@ -116,13 +120,23 @@ int main(void) spinlock_data->data =2 ;/* Wait until child ends */ -wait (NULL ); +wait (&status);if ((shm_unlink (shm_name)) !=0 ) {perror ("Error at shm_unlink()" );return PTS_UNRESOLVED ; } +if (!WIFEXITED (status)) { +printf ("Parent: did not exit properly!\n" ); +return PTS_FAIL ; + } + +if (WEXITSTATUS (status)) { +printf ("Parent: failure in child\n" ); +return WEXITSTATUS (status); + } +printf ("Test PASSED\n" );return PTS_PASS ; }else {@@ -170,5 +184,7 @@ int main(void)printf ("Child: error at pthread_spin_destroy()\n" );return PTS_UNRESOLVED ; } + +return PTS_PASS ; } }testcases/open_posix_testsuite/conformance/interfaces/pthread_spin_init/2-2.c +18
-2@@ -106,7 +106,11 @@ int main(void)if (pid ==-1 ) {perror ("Error at fork()" );return PTS_UNRESOLVED ; - }else if (pid >0 ) { + } + +if (pid >0 ) { +int status; +/* Parent */ /* wait until child writes to spinlock data */ while (spinlock_data->data !=1 )@@ -122,13 +126,23 @@ int main(void) spinlock_data->data =2 ;/* Wait until child ends */ -wait (NULL ); +wait (&status);if ((shm_unlink (shm_name)) !=0 ) {perror ("Error at shm_unlink()" );return PTS_UNRESOLVED ; } +if (!WIFEXITED (status)) { +printf ("Parent: did not exit properly!\n" ); +return PTS_FAIL ; + } + +if (WEXITSTATUS (status)) { +printf ("Parent: failure in child\n" ); +return WEXITSTATUS (status); + } +printf ("Test PASSED\n" );return PTS_PASS ; }else {@@ -175,5 +189,7 @@ int main(void)printf ("Child: error at pthread_spin_destroy()\n" );return PTS_UNRESOLVED ; } + +return PTS_PASS ; } }Signature · 1 line
2.35.1
Signature · 5 lines
Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 3/7 openposix: sem_destroy/3-1: Fix
In reply to Cyril HrubisThere were several problems in the test and it actually didn't even call the sem_destroy() function at all.
- The main thread did call thread_exit() before actually attempting to destroy the semaphores
- The program exit value was undefined (random garbage) in the unlikely case that pthread_join() failed for one of the threads
--- .../conformance/interfaces/sem_destroy/3-1.c | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-)
testcases/open_posix_testsuite/conformance/interfaces/sem_destroy/3-1.c +22 -9
@@ -19,11 +19,11 @@#include <sys/stat.h> #include <fcntl.h> #include <pthread.h> +#include <string.h> #include "posixtest.h" #define TEST "3-1"#define FUNCTION "sem_destroy" -#define ERROR_PREFIX "unexpected error: " FUNCTION " " TEST ": "static sem_t psem, csem;static int n;
@@ -33,6 +33,7 @@ static void *consumer(void *);int main (void ) {pthread_t prod, cons; +int err;long cnt =3 ; n =0 ;
@@ -40,28 +41,40 @@ int main(void)perror ("sem_init" );return PTS_UNRESOLVED ; } +if (sem_init (&psem,0 ,1 ) <0 ) {perror ("sem_init" );return PTS_UNRESOLVED ; } +if (pthread_create (&prod,NULL , producer, (void *)cnt) !=0 ) {perror ("pthread_create" );return PTS_UNRESOLVED ; } +if (pthread_create (&cons,NULL , consumer, (void *)cnt) !=0 ) {perror ("pthread_create" );return PTS_UNRESOLVED ; } -if (pthread_join (prod,NULL ) ==0 &&pthread_join (cons,NULL ) ==0 ) { + err =pthread_join (prod,NULL ); +if (err) { +printf ("Failed to join thread: %s" ,strerror (err)); +return PTS_UNRESOLVED ; + } + + err =pthread_join (cons,NULL ); +if (err) { +printf ("Failed to join thread: %s" ,strerror (err)); +return PTS_UNRESOLVED ; + } + +if (sem_destroy (&psem) ==0 &&sem_destroy (&csem) ==0 ) {puts ("TEST PASS" ); -pthread_exit (NULL ); -if ((sem_destroy (&psem) ==0 ) &&sem_destroy (&csem) ==0 ) { -return PTS_PASS ; - }else { -puts ("TEST FAILED" ); -return PTS_FAIL ; - } +return PTS_PASS ; + }else { +puts ("TEST FAILED" ); +return PTS_FAIL ; } }
Signature · 5 lines
2.35.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 3/7] openposix: sem_destroy/3-1: Fix
Hello,
testcases/open_posix_testsuite/conformance/interfaces/sem_destroy/3-1.c int main(void) · line 58
Quoted 3 lines · Cyril Hrubis
testcases/open_posix_testsuite/conformance/interfaces/sem_destroy/3-1.c +1
-1+if (sem_destroy (&psem) ==0 &&sem_destroy (&csem) ==0 ) {puts ("TEST PASS" ); -pthread_exit (NULL );
lol
Quoted 15 lines
testcases/open_posix_testsuite/conformance/interfaces/sem_destroy/3-1.c +4
-6-if ((sem_destroy (&psem) ==0 ) &&sem_destroy (&csem) ==0 ) { -return PTS_PASS ; - }else { -puts ("TEST FAILED" ); -return PTS_FAIL ; - } +return PTS_PASS ; + }else { +puts ("TEST FAILED" ); +return PTS_FAIL ; } }Signature · 2 lines
-- 2.35.1
Signature · 5 lines
Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 4/7 openposix: sem_timedwait/11-1: Fix
In reply to Cyril HrubisActually run both of the cases (valid timeout and invalid timeout).
The timeout is not actually invalid, but rather in the past, which is important to test as the system has to try to lock the semaphore first and only if that fails it should check the timeout.
--- .../conformance/interfaces/sem_timedwait/11-1.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
testcases/open_posix_testsuite/conformance/interfaces/sem_timedwait/11-1.c +5 -4
@@ -24,7 +24,7 @@#include "posixtest.h" #define TIMEOUT 2 -#define INVALIDTIMEOUT -2 +#define NEGATIVETIMEOUT -2#define TEST "11-1"#define FUNCTION "sem_timedwait"#define ERROR_PREFIX "unexpected error: " FUNCTION " " TEST ": "
@@ -45,7 +45,7 @@ int main(void) ts[i].tv_sec =time (NULL ) +TIMEOUT ; ts[i].tv_nsec =0 ; }else if (i ==1 ) { - ts[i].tv_sec =time (NULL ) +INVALIDTIMEOUT ; + ts[i].tv_sec =time (NULL ) +NEGATIVETIMEOUT ; ts[i].tv_nsec =0 ; }/* Lock Semaphore */
@@ -63,13 +63,14 @@ int main(void)/* Checking if the value of the Semaphore decremented by one */ if ((val[i] ==0 ) && (sts[i] ==0 )) { -puts ("TEST PASSED" );sem_destroy (&mysemp[i]); -return PTS_PASS ; }else {puts ("TEST FAILED" );sem_destroy (&mysemp[i]);return PTS_FAIL ; } } + +puts ("TEST PASSED" ); +return PTS_PASS ; }
Signature · 5 lines
2.35.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 4/7] openposix: sem_timedwait/11-1: Fix
Hi,
small suggestion below, otherwise it looks good.
Quoted 34 lines · Cyril Hrubis
Actually run both of the cases (valid timeout and invalid timeout).
The timeout is not actually invalid, but rather in the past, which is important to test as the system has to try to lock the semaphore first and only if that fails it should check the timeout.
Signed-off-by Cyril Hrubis <[email protected]>--- .../conformance/interfaces/sem_timedwait/11-1.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)testcases/open_posix_testsuite/conformance/interfaces/sem_timedwait/11-1.c +2
-2@@ -24,7 +24,7 @@#include "posixtest.h" #define TIMEOUT 2 -#define INVALIDTIMEOUT -2 +#define NEGATIVETIMEOUT -2#define TEST "11-1"#define FUNCTION "sem_timedwait"#define ERROR_PREFIX "unexpected error: " FUNCTION " " TEST ": "@@ -45,7 +45,7 @@ int main(void) ts[i].tv_sec =time (NULL ) +TIMEOUT ; ts[i].tv_nsec =0 ; }else if (i ==1 ) { - ts[i].tv_sec =time (NULL ) +INVALIDTIMEOUT ; + ts[i].tv_sec =time (NULL ) +NEGATIVETIMEOUT ; ts[i].tv_nsec =0 ; }/* Lock Semaphore */
testcases/open_posix_testsuite/conformance/interfaces/sem_timedwait/11-1.c int main(void) · line 66
Quoted 5 lines
testcases/open_posix_testsuite/conformance/interfaces/sem_timedwait/11-1.c +0
-1@@ -63,13 +63,14 @@ int main(void)/* Checking if the value of the Semaphore decremented by one */ if ((val[i] ==0 ) && (sts[i] ==0 )) { -puts ("TEST PASSED" );sem_destroy (&mysemp[i]);
It'd be better to move sem_destroy() above the condition. See code example at the end.
Quoted 11 lines
testcases/open_posix_testsuite/conformance/interfaces/sem_timedwait/11-1.c +3
-1-return PTS_PASS ; }else {puts ("TEST FAILED" );sem_destroy (&mysemp[i]);return PTS_FAIL ; } } + +puts ("TEST PASSED" ); +return PTS_PASS ; }
...
sem_destroy(&mysemp[i]);
/* Checking if the value of the Semaphore decremented by one */
if ((val[i] != 0) || (sts[i] != 0)) {
puts("TEST FAILED");
return PTS_FAIL;
}
puts("TEST PASSED");
return PTS_PASS;
}Signature · 10 lines
Martin Doucha [email protected] QA Engineer for Software Maintenance SUSE LINUX, s.r.o. CORSO IIa Krizikova 148/34 186 00 Prague 8 Czech Republic -- Mailing list info: https://lists.linux.it/listinfo/ltp
Richard Palethorpe
Reviewed-byRe: [LTP] [PATCH 4/7] openposix: sem_timedwait/11-1: Fix
Hello,
Quoted 63 lines · Martin Doucha
Hi,
small suggestion below, otherwise it looks good.Reviewed-by Martin Doucha <[email protected]>Quoted 34 lines · Cyril Hrubis
Actually run both of the cases (valid timeout and invalid timeout).
The timeout is not actually invalid, but rather in the past, which is important to test as the system has to try to lock the semaphore first and only if that fails it should check the timeout.
Signed-off-by Cyril Hrubis <[email protected]>--- .../conformance/interfaces/sem_timedwait/11-1.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)testcases/open_posix_testsuite/conformance/interfaces/sem_timedwait/11-1.c +2
-2@@ -24,7 +24,7 @@#include "posixtest.h" #define TIMEOUT 2 -#define INVALIDTIMEOUT -2 +#define NEGATIVETIMEOUT -2#define TEST "11-1"#define FUNCTION "sem_timedwait"#define ERROR_PREFIX "unexpected error: " FUNCTION " " TEST ": "@@ -45,7 +45,7 @@ int main(void) ts[i].tv_sec =time (NULL ) +TIMEOUT ; ts[i].tv_nsec =0 ; }else if (i ==1 ) { - ts[i].tv_sec =time (NULL ) +INVALIDTIMEOUT ; + ts[i].tv_sec =time (NULL ) +NEGATIVETIMEOUT ; ts[i].tv_nsec =0 ; }/* Lock Semaphore */ testcases/open_posix_testsuite/conformance/interfaces/sem_timedwait/11-1.c int main(void) · line 66
Quoted 5 lines
testcases/open_posix_testsuite/conformance/interfaces/sem_timedwait/11-1.c +0
-1@@ -63,13 +63,14 @@ int main(void)/* Checking if the value of the Semaphore decremented by one */ if ((val[i] ==0 ) && (sts[i] ==0 )) { -puts ("TEST PASSED" );sem_destroy (&mysemp[i]);It'd be better to move
sem_destroy()above the condition. See code example at the end.Quoted 11 lines
testcases/open_posix_testsuite/conformance/interfaces/sem_timedwait/11-1.c +3
-1-return PTS_PASS ; }else {puts ("TEST FAILED" );sem_destroy (&mysemp[i]);return PTS_FAIL ; } } + +puts ("TEST PASSED" ); +return PTS_PASS ; }...
Quoted 1 line
sem_destroy(&mysemp[i]);
And with that also:
Quoted 19 lines
/* Checking if the value of the Semaphore decremented by one */ if ((val[i] != 0) || (sts[i] != 0)) { puts("TEST FAILED"); return PTS_FAIL; } puts("TEST PASSED"); return PTS_PASS; }Signature · 7 lines
Martin Doucha [email protected] QA Engineer for Software Maintenance SUSE LINUX, s.r.o. CORSO IIa Krizikova 148/34 186 00 Prague 8 Czech Republic
Signature · 5 lines
Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 5/7 openposix: aio_h/2-1: Add return at the end of main()
In reply to Cyril HrubisThis is compile-only test so the return value is not actually used but that's not a reason not to fix warnings.
--- .../open_posix_testsuite/conformance/definitions/aio_h/2-1.c | 2 ++ 1 file changed, 2 insertions(+)
testcases/open_posix_testsuite/conformance/definitions/aio_h/2-1.c +2 -0
@@ -25,4 +25,6 @@ int main(void) aiocb.aio_nbytes =0 ; aiocb.aio_sigevent = sigevent; aiocb.aio_reqprio =-1 ; + +return 0 ; }
Signature · 5 lines
2.35.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 5/7] openposix: aio_h/2-1: Add return at the end of main()
Quoted 21 lines · Cyril Hrubis
This is compile-only test so the return value is not actually used but that's not a reason not to fix warnings.
Signed-off-by Cyril Hrubis <[email protected]>--- .../open_posix_testsuite/conformance/definitions/aio_h/2-1.c | 2 ++ 1 file changed, 2 insertions(+)testcases/open_posix_testsuite/conformance/definitions/aio_h/2-1.c +2
-0@@ -25,4 +25,6 @@ int main(void) aiocb.aio_nbytes =0 ; aiocb.aio_sigevent = sigevent; aiocb.aio_reqprio =-1 ; + +return 0 ; }Signature · 1 line
2.35.1
Signature · 5 lines
Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 6/7 openposix: mq_timedreceive: Silence warning
In reply to Cyril HrubisWe do not use the exit value from the child at all, but that's not a reason to produce warnings.
--- .../conformance/interfaces/mq_timedreceive/5-3.c | 1 + 1 file changed, 1 insertion(+)
testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/5-3.c +1 -0
@@ -110,5 +110,6 @@ int main(void)sleep (1 );/* give time to parent to set up handler */ /* send signal to parent */ kill (getppid (),SIGABRT ); +return 0 ; } }
Signature · 5 lines
2.35.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 6/7] openposix: mq_timedreceive: Silence warning
Quoted 21 lines · Cyril Hrubis
We do not use the exit value from the child at all, but that's not a reason to produce warnings.
Signed-off-by Cyril Hrubis <[email protected]>--- .../conformance/interfaces/mq_timedreceive/5-3.c | 1 + 1 file changed, 1 insertion(+)testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/5-3.c +1
-0@@ -110,5 +110,6 @@ int main(void)sleep (1 );/* give time to parent to set up handler */ /* send signal to parent */ kill (getppid (),SIGABRT ); +return 0 ; } }Signature · 1 line
2.35.1
Signature · 5 lines
Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 7/7 opeposix: pthread_barrierattr_getpshared/2-1: Simplify codeflow
In reply to Cyril HrubisThis actually fixes a 'no return in nonvoid function' warning since gcc may get confused during the codeflow analysis.
--- .../interfaces/pthread_barrierattr_getpshared/2-1.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
testcases/open_posix_testsuite/conformance/interfaces/pthread_barrierattr_getpshared/2-1.c +5 -6
@@ -141,7 +141,9 @@ int main(void)if (pid ==-1 ) {perror ("Error at fork()" );return PTS_UNRESOLVED ; - }else if (pid ==0 ) { + } + +if (pid ==0 ) {/* Child */ /* Map the shared object to child's memory */ barrier =
@@ -209,10 +211,7 @@ int main(void)printf ("Test PASSED\n" );return PTS_PASS ; + }else { +return serial; } - -if (pid ==0 ) { -exit (serial); - } - }
Signature · 5 lines
2.35.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 7/7] opeposix: pthread_barrierattr_getpshared/2-1: Simplify codeflow
Hi,
one small suggestion below, otherwise for the whole patchset:
Quoted 24 lines · Cyril Hrubis
This actually fixes a 'no return in nonvoid function' warning since gcc may get confused during the codeflow analysis.
Signed-off-by Cyril Hrubis <[email protected]>--- .../interfaces/pthread_barrierattr_getpshared/2-1.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)testcases/open_posix_testsuite/conformance/interfaces/pthread_barrierattr_getpshared/2-1.c +3
-1@@ -141,7 +141,9 @@ int main(void)if (pid ==-1 ) {perror ("Error at fork()" );return PTS_UNRESOLVED ; - }else if (pid ==0 ) { + } + +if (pid ==0 ) {/* Child */ /* Map the shared object to child's memory */ barrier =
testcases/open_posix_testsuite/conformance/interfaces/pthread_barrierattr_getpshared/2-1.c int main(void) · line 215
Quoted 5 lines
testcases/open_posix_testsuite/conformance/interfaces/pthread_barrierattr_getpshared/2-1.c +2
-0@@ -209,10 +211,7 @@ int main(void)printf ("Test PASSED\n" );return PTS_PASS ; + }else { +return serial;
The return can be unconditional.
Quoted 7 lines
testcases/open_posix_testsuite/conformance/interfaces/pthread_barrierattr_getpshared/2-1.c +0
-5} - -if (pid ==0 ) { -exit (serial); - } - }
Signature · 10 lines
Martin Doucha [email protected] QA Engineer for Software Maintenance SUSE LINUX, s.r.o. CORSO IIa Krizikova 148/34 186 00 Prague 8 Czech Republic -- Mailing list info: https://lists.linux.it/listinfo/ltp
Richard Palethorpe
Reviewed-byRe: [LTP] [PATCH 7/7] opeposix: pthread_barrierattr_getpshared/2-1: Simplify codeflow
Hello,
Quoted 31 lines · Martin Doucha
Hi,
one small suggestion below, otherwise for the whole patchset:Reviewed-by Martin Doucha <[email protected]>Quoted 25 lines · Cyril Hrubis
This actually fixes a 'no return in nonvoid function' warning since gcc may get confused during the codeflow analysis.
Signed-off-by Cyril Hrubis <[email protected]>--- .../interfaces/pthread_barrierattr_getpshared/2-1.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)testcases/open_posix_testsuite/conformance/interfaces/pthread_barrierattr_getpshared/2-1.c +3
-1@@ -141,7 +141,9 @@ int main(void)if (pid ==-1 ) {perror ("Error at fork()" );return PTS_UNRESOLVED ; - }else if (pid ==0 ) { + } + +if (pid ==0 ) {/* Child */ /* Map the shared object to child's memory */ barrier =@@ -209,10 +211,7 @@ int main(void)
Quoted 6 lines
testcases/open_posix_testsuite/conformance/interfaces/pthread_barrierattr_getpshared/2-1.c int main(void) · line 215
Quoted 4 lines
testcases/open_posix_testsuite/conformance/interfaces/pthread_barrierattr_getpshared/2-1.c +2
-0printf ("Test PASSED\n" );return PTS_PASS ; + }else { +return serial;The return can be unconditional.
And with that also:
Quoted 18 lines
Quoted 8 lines
testcases/open_posix_testsuite/conformance/interfaces/pthread_barrierattr_getpshared/2-1.c +0
-5} - -if (pid ==0 ) { -exit (serial); - } - }Signature · 7 lines
Martin Doucha [email protected] QA Engineer for Software Maintenance SUSE LINUX, s.r.o. CORSO IIa Krizikova 148/34 186 00 Prague 8 Czech Republic
Signature · 5 lines
Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH 7/7] opeposix: pthread_barrierattr_getpshared/2-1: Simplify codeflow
In reply to Martin DouchaHi!
Quoted 4 lines
testcases/open_posix_testsuite/conformance/interfaces/pthread_barrierattr_getpshared/2-1.c int main(void) · line 215
Quoted 2 lines
testcases/open_posix_testsuite/conformance/interfaces/pthread_barrierattr_getpshared/2-1.c +2
-0+ }else { +return serial;The return can be unconditional.
I changed the code a bit more in the end to make it even more readable, now it's structured as:
if (pid == 0)
return serial;
/* parent */
if (wait(&status) != pid) {
...
}
...
printf("Test PASSED\n");
return PTS_PASS;Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Cyril,
Generally looks good, thanks for the fix and cleanup. Tests work well from my side.
For the series:
Signature · 2 lines
Regards, Li Wang
Signature · 2 lines
-- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
I've adjusted the patches accordingly to suggestions from Martin and pushed the patchset. Thanks everyone for the review.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp