[Cbe-oss-dev] [PATCH 5/10] MARS: fix pthread return val

Yuji Mano Yuji.Mano at am.sony.com
Wed Aug 6 04:54:19 EST 2008


This fixes incorrect usage of the pthread return values.

Signed-off-by: Yuji Mano <yuji.mano at am.sony.com>

---
 src/host/lib/mars.c |   26 +++++++++-----------------
 1 file changed, 9 insertions(+), 17 deletions(-)

--- a/src/host/lib/mars.c
+++ b/src/host/lib/mars.c
@@ -63,25 +63,18 @@ static void *mpu_context_thread(void *ar
 	struct spe_context *spe;
 
 	spe = spe_context_create(0, NULL);
-	MARS_CHECK_CLEANUP_RET(spe, ret = MARS_ERROR_INTERNAL;
-				pthread_exit(&ret), NULL);
+	MARS_CHECK_RET(spe, (void *)MARS_ERROR_INTERNAL);
 
 	ret = spe_program_load(spe, &mars_kernel_entry);
-	MARS_CHECK_CLEANUP_RET(!ret, ret = MARS_ERROR_INTERNAL;
-				pthread_exit(&ret), NULL);
+	MARS_CHECK_RET(!ret, (void *)MARS_ERROR_INTERNAL);
 
-	ret = spe_context_run(spe, &entry, 0,
-				params, NULL, NULL);
-	MARS_CHECK_CLEANUP_RET(!ret, ret = MARS_ERROR_INTERNAL;
-				pthread_exit(&ret), NULL);
+	ret = spe_context_run(spe, &entry, 0, params, NULL, NULL);
+	MARS_CHECK_RET(!ret, (void *)MARS_ERROR_INTERNAL);
 
 	ret = spe_context_destroy(spe);
-	MARS_CHECK_CLEANUP_RET(!ret, ret = MARS_ERROR_INTERNAL;
-				pthread_exit(&ret), NULL);
+	MARS_CHECK_RET(!ret, (void *)MARS_ERROR_INTERNAL);
 
-	pthread_exit(MARS_SUCCESS);
-
-	return NULL;
+	return (void *)MARS_SUCCESS;
 }
 
 static int create_mpu_contexts(struct mars_context *mars, int num_mpu_contexts)
@@ -115,14 +108,13 @@ static int destroy_mpu_contexts(struct m
 	MARS_ASSERT(mars);
 
 	int ret;
-	int thread_ret;
-	void *ptr = &thread_ret;
+	void *p_ret;
 	unsigned int i;
 
 	/* join all mpu context threads */
 	for (i = 0; i < mars->mpu_context_count; i++) {
-		ret = pthread_join(mars->mpu_context_threads[i], &ptr);
-		MARS_CHECK_RET(!ret, thread_ret);
+		ret = pthread_join(mars->mpu_context_threads[i], &p_ret);
+		MARS_CHECK_RET(!ret && !p_ret, MARS_ERROR_INTERNAL);
 	}
 
 	return MARS_SUCCESS;





More information about the cbe-oss-dev mailing list