Helper defines that pthread exit status is NULL on error,
but checks for != NULL. Both NULL and !NULL were returned
on failure.

Defined that both process and pthread return !0 (!NULL) on
failure.

Signed-off-by: Petri Savolainen <[email protected]>
---
 helper/linux.c       | 15 ++++++++++-----
 helper/test/thread.c |  2 +-
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/helper/linux.c b/helper/linux.c
index 8b9dbe8..a1dbe52 100644
--- a/helper/linux.c
+++ b/helper/linux.c
@@ -261,7 +261,7 @@ static void *odpthread_run_start_routine(void *arg)
                ODPH_ERR("Local init failed\n");
                if (start_args->linuxtype == ODPTHREAD_PROCESS)
                        _exit(EXIT_FAILURE);
-               return NULL;
+               return (void *)-1;
        }
 
        ODPH_DBG("helper: ODP %s thread started as linux %s. (pid=%d)\n",
@@ -284,7 +284,7 @@ static void *odpthread_run_start_routine(void *arg)
                _exit(status);
 
        /* threads implementation return void* pointers: cast status to that. */
-       return (void *)(long)status;
+       return (void *)(intptr_t)status;
 }
 
 /*
@@ -426,8 +426,10 @@ int odph_odpthreads_join(odph_odpthread_t *thread_tbl)
        pid_t pid;
        int i = 0;
        int terminated = 0;
-       int status = 0;         /* child process return code (!=0 is error) */
-       void *thread_ret;       /* "child" thread return code (NULL is error) */
+       /* child process return code (!=0 is error) */
+       int status = 0;
+       /* "child" thread return code (!NULL is error) */
+       void *thread_ret = NULL;
        int ret;
        int retval = 0;
 
@@ -445,8 +447,11 @@ int odph_odpthreads_join(odph_odpthread_t *thread_tbl)
                                retval = -1;
                        } else {
                                terminated++;
-                               if (thread_ret != NULL)
+                               if (thread_ret != NULL) {
+                                       ODPH_ERR("Bad exit status cpu #%d %p\n",
+                                                thread_tbl[i].cpu, thread_ret);
                                        retval = -1;
+                               }
                        }
                        pthread_attr_destroy(&thread_tbl[i].thread.attr);
                        break;
diff --git a/helper/test/thread.c b/helper/test/thread.c
index b290753..8268d9f 100644
--- a/helper/test/thread.c
+++ b/helper/test/thread.c
@@ -17,7 +17,7 @@ static void *worker_fn(void *arg TEST_UNUSED)
 
        /* depend on the odp helper to call odp_term_local */
 
-       return 0;
+       return NULL;
 }
 
 /* Create additional dataplane threads */
-- 
2.8.1

_______________________________________________
lng-odp mailing list
[email protected]
https://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to