[Cbe-oss-dev] [PATCH] libspe2: Fix return value of spe_ps_area_get

Kazunori Asayama asayama at sm.sony.co.jp
Tue Apr 10 23:47:14 EST 2007


The spec of libspe2 requires spe_ps_area_get() to return NULL in error
condition, but the current implementation returns (void*)-1. Here is a
patch to fix the problem.

OK to apply ?

Signed-off-by: Kazunori Asayama <asayama at sm.sony.co.jp>

Index: libspe2-public/spebase/accessors.c
===================================================================
--- libspe2-public.orig/spebase/accessors.c
+++ libspe2-public/spebase/accessors.c
@@ -20,6 +20,7 @@
 #include "create.h"
 
 #include <fcntl.h>
+#include <errno.h>
 
  /*
  * accessor functions for private members 
@@ -37,24 +38,36 @@ int _base_spe_stop_status_get(spe_contex
 
 void* _base_spe_ps_area_get(spe_context_ptr_t spe, enum ps_area area)
 {
+	void *ptr;
+
 	switch (area) {
 		case SPE_MSSYNC_AREA:
-			return spe->base_private->mssync_mmap_base;
+			ptr = spe->base_private->mssync_mmap_base;
 			break;
 		case SPE_MFC_COMMAND_AREA:
-			return spe->base_private->mfc_mmap_base;
+			ptr = spe->base_private->mfc_mmap_base;
 			break;
 		case SPE_CONTROL_AREA:
-			return spe->base_private->cntl_mmap_base;
+			ptr = spe->base_private->cntl_mmap_base;
 			break;
 		case SPE_SIG_NOTIFY_1_AREA:
-			return spe->base_private->signal1_mmap_base;
+			ptr = spe->base_private->signal1_mmap_base;
 			break;
 		case SPE_SIG_NOTIFY_2_AREA:
-			return spe->base_private->signal2_mmap_base;
+			ptr = spe->base_private->signal2_mmap_base;
+			break;
+		default:
+			errno = EINVAL;
+			return NULL;
 			break;
 	}
-	return (void*) -1;
+
+	if (ptr == (void*)-1) {
+		errno = EACCES;
+		return NULL;
+	}
+
+	return ptr;
 }
 
 void* _base_spe_ls_area_get(spe_context_ptr_t spe)



More information about the cbe-oss-dev mailing list