Fix the prototype and remove the (void *) casts.

Add error checks to:
    Make sure this case not slip into one situation that
    the first pthread_once fails, and the second successes,
    then the case passes with bypassing its assertion.

    Give more detailed and exact execute result.


Signed-off-by: DAN LI <[email protected]>
---
 .../conformance/interfaces/pthread_once/1-1.c         | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git 
a/testcases/open_posix_testsuite/conformance/interfaces/pthread_once/1-1.c
b/testcases/open_posix_testsuite/conformance/interfaces/pthread_once/1-1.c
index 3a7c861..7504f6c 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_once/1-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_once/1-1.c
@@ -26,10 +26,10 @@
 #include "posixtest.h"

 /* Keeps track of how many times the init function has been called. */
-int init_flag;
+static int init_flag;

 /* The init function that pthread_once calls */
-void *an_init_func()
+void an_init_func(void)
 {
        init_flag++;
        return NULL;
@@ -37,16 +37,25 @@ void *an_init_func()

 int main()
 {
+       int ret;
+
        pthread_once_t once_control = PTHREAD_ONCE_INIT;

        init_flag = 0;

        /* Call pthread_once, passing it the once_control */
-       pthread_once(&once_control, (void *)an_init_func);
-
+       ret = pthread_once(&once_control, an_init_func);
+       if (ret != 0) {
+               printf("pthread_once failed\n");
+               return PTS_UNRESOLVED;
+       }
        /* Call pthread_once again. The init function should not be
         * called. */
-       pthread_once(&once_control, (void *)an_init_func);
+       ret = pthread_once(&once_control, an_init_func);
+       if (ret != 0) {
+               printf("pthread_once failed\n");
+               return PTS_UNRESOLVED;
+       }

        if (init_flag != 1) {
                printf("Test FAILED\n");
-- 
1.7.12

------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester  
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the  
endpoint security space. For insight on selecting the right partner to 
tackle endpoint security challenges, access the full report. 
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to