commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r806092 - in /commons/sandbox/runtime/trunk/src/main/native: include/acr_error.h os/darwin/pmutex.c os/hpux/pshm.c os/unix/pmutex.c os/unix/psema.c os/unix/pshm.c os/win32/pmutex.c os/win32/psema.c os/win32/pshm.c shared/shm.c
Date Thu, 20 Aug 2009 08:59:18 GMT
Author: mturk
Date: Thu Aug 20 08:59:17 2009
New Revision: 806092

URL: http://svn.apache.org/viewvc?rev=806092&view=rev
Log:
Use THROW macros instead repeating the code all over the place

Modified:
    commons/sandbox/runtime/trunk/src/main/native/include/acr_error.h
    commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c
    commons/sandbox/runtime/trunk/src/main/native/os/hpux/pshm.c
    commons/sandbox/runtime/trunk/src/main/native/os/unix/pmutex.c
    commons/sandbox/runtime/trunk/src/main/native/os/unix/psema.c
    commons/sandbox/runtime/trunk/src/main/native/os/unix/pshm.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/pmutex.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/psema.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/pshm.c
    commons/sandbox/runtime/trunk/src/main/native/shared/shm.c

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_error.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_error.h?rev=806092&r1=806091&r2=806092&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_error.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_error.h Thu Aug 20 08:59:17
2009
@@ -128,6 +128,25 @@
 
 #endif /* HAVE_MEMPROTECT */
 
+#define ACR_THROW_IO_IF_ERR(S)                                              \
+    if ((S) && IS_VALID_HANDLE(_E)) {                                       \
+        if (ACR_STATUS_IS_EACCES((S)))                                      \
+            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);       \
+        else                                                                \
+            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, (S));           \
+        ACR_SET_OS_ERROR((S));                                              \
+    } else _E = _E
+
+#define ACR_THROW_IO_ERRNO()                                                \
+    if (IS_VALID_HANDLE(_E)) {                                              \
+        int _se = ACR_GET_OS_ERROR();                                       \
+        if (ACR_STATUS_IS_EACCES(_se))                                      \
+            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);       \
+        else                                                                \
+            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, _se);           \
+        ACR_SET_OS_ERROR(_se);                                              \
+    } else _E = _E
+
 /*
  * Convenience function to help throw any class
  * @param env JNI Environment

Modified: commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c?rev=806092&r1=806091&r2=806092&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c Thu Aug 20 08:59:17 2009
@@ -109,13 +109,7 @@
     if (rc) {
         free(m->fname);
         free(m);
-        if (IS_VALID_HANDLE(_E)) {
-            if (ACR_STATUS_IS_EACCES(rc))
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-            else
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, rc);
-        }
-        ACR_SET_OS_ERROR(rc);
+        ACR_THROW_IO_IF_ERR(rc);
         return -1;
     }
     else {
@@ -137,8 +131,7 @@
     acr_pmutex_t *m = (acr_pmutex_t *)ACR_IOH(mutex);
 
     if (IS_INVALID_HANDLE(m) || ACR_IOH_TYPE(mutex) != ACR_DT_MUTEX) {
-        ACR_SET_OS_ERROR(ACR_EINVAL);
-        return -1;
+        return ACR_EINVAL;
     }        
 
     op.l_whence = SEEK_SET;   /* from current point */

Modified: commons/sandbox/runtime/trunk/src/main/native/os/hpux/pshm.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/hpux/pshm.c?rev=806092&r1=806091&r2=806092&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/hpux/pshm.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/hpux/pshm.c Thu Aug 20 08:59:17 2009
@@ -143,12 +143,7 @@
     int rv;
 
     rv = acr_ioh_close(shm);
-    if (rv  && IS_VALID_HANDLE(_E)) {
-        if (rv == EACCES)
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-        else
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, rv);
-    }
+    ACR_THROW_IO_IF_ERR(rv);
     return rv;
 }
 
@@ -195,12 +190,7 @@
 
 finally:
     unlink(filename);
-    if (rc  && IS_VALID_HANDLE(_E)) {
-        if (rc == EACCES)
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-        else
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, rc);
-    }
+    ACR_THROW_IO_IF_ERR(rc);
     return rc;
 }
 
@@ -260,13 +250,7 @@
 anonerr:
         if (rc) {
             free(shm);
-            if (IS_VALID_HANDLE(_E)) {
-                if (rc == EACCES)
-                    ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-                else
-                    ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, rc);
-            }
-            ACR_SET_OS_ERROR(rc);
+            ACR_THROW_IO_IF_ERR(rc);
             return -1;
         }
     }
@@ -341,13 +325,7 @@
         if (rc) {
             free((void *)(shm->filename));
             free(shm);
-            if (IS_VALID_HANDLE(_E)) {
-                if (rc == EACCES)
-                    ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-                else
-                    ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, rc);
-            }
-            ACR_SET_OS_ERROR(rc);
+            ACR_THROW_IO_IF_ERR(rc);
             shm = NULL;
         }
     }
@@ -430,13 +408,7 @@
     if (rc) {
         free((void *)(shm->filename));
         free(shm);
-        if (IS_VALID_HANDLE(_E)) {
-            if (rc == EACCES)
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-            else
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, rc);
-        }
-        ACR_SET_OS_ERROR(rc);
+        ACR_THROW_IO_IF_ERR(rc);
         shm = NULL;
     }
     if (shm) {
@@ -461,12 +433,7 @@
 
     rc = acr_ioh_close(shm);
 finally:
-    if (rc  && IS_VALID_HANDLE(_E)) {
-        if (rc == EACCES)
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-        else
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, rc);
-    }
+    ACR_THROW_IO_IF_ERR(rc);
     return rc;
 }
 
@@ -495,12 +462,7 @@
     }
 
 finally:
-    if (rc && IS_VALID_HANDLE(_E)) {
-        if (rc == EACCES)
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-        else
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, rc);
-    }
+    ACR_THROW_IO_IF_ERR(rc);
     return rc;
 }
 

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/pmutex.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/pmutex.c?rev=806092&r1=806091&r2=806092&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/pmutex.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/pmutex.c Thu Aug 20 08:59:17 2009
@@ -96,13 +96,7 @@
             semctl(m->filedes, 0, IPC_RMID, ick);
         }
         free(m);
-        if (IS_VALID_HANDLE(_E)) {
-            if (ACR_STATUS_IS_EACCES(rc))
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-            else
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, rc);
-        }
-        ACR_SET_OS_ERROR(rc);
+        ACR_THROW_IO_IF_ERR(rc);
         return -1;
     }
     else {

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/psema.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/psema.c?rev=806092&r1=806091&r2=806092&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/psema.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/psema.c Thu Aug 20 08:59:17 2009
@@ -122,13 +122,7 @@
 finally:
     if (rc) {
         free(s);
-        if (IS_VALID_HANDLE(_E)) {
-            if (ACR_STATUS_IS_EACCES(rc))
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-            else
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, rc);
-        }
-        ACR_SET_OS_ERROR(rc);
+        ACR_THROW_IO_IF_ERR(rc);
         return -1;
     }
     else {
@@ -162,13 +156,7 @@
 finally:
     if (rc) {
         x_free(s);
-        if (IS_VALID_HANDLE(_E)) {
-            if (ACR_STATUS_IS_EACCES(rc))
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-            else
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, rc);
-        }
-        ACR_SET_OS_ERROR(rc);
+        ACR_THROW_IO_IF_ERR(rc);
         return -1;
     }
     else {

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/pshm.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/pshm.c?rev=806092&r1=806091&r2=806092&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/pshm.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/pshm.c Thu Aug 20 08:59:17 2009
@@ -323,10 +323,7 @@
             free((void *)(shm->filename));
             free(shm);
             if (IS_VALID_HANDLE(_E)) {
-                if (ACR_STATUS_IS_EACCES(rc))
-                    ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-                else
-                    ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, rc);
+                ACR_THROW_EIO(rc);
             }
             ACR_SET_OS_ERROR(rc);
             shm = NULL;
@@ -412,10 +409,7 @@
         free((void *)(shm->filename));
         free(shm);
         if (IS_VALID_HANDLE(_E)) {
-            if (ACR_STATUS_IS_EACCES(rc))
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-            else
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, rc);
+            ACR_THROW_EIO(rc);
         }
         ACR_SET_OS_ERROR(rc);
         shm = NULL;
@@ -443,10 +437,7 @@
     rc = acr_ioh_close(shm);
 finally:
     if (rc  && IS_VALID_HANDLE(_E)) {
-        if (ACR_STATUS_IS_EACCES(rc))
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-        else
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, rc);
+        ACR_THROW_EIO(rc);
     }
     return rc;
 }
@@ -477,10 +468,7 @@
 
 finally:
     if (rc && IS_VALID_HANDLE(_E)) {
-        if (ACR_STATUS_IS_EACCES(rc))
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-        else
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, rc);
+        ACR_THROW_EIO(rc);
     }
     return rc;
 }

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/pmutex.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/pmutex.c?rev=806092&r1=806091&r2=806092&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/pmutex.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/pmutex.c Thu Aug 20 08:59:17 2009
@@ -76,14 +76,7 @@
     sa.bInheritHandle = FALSE;
     m = CreateMutexW(&sa, FALSE, reskey);
     if (!m) {
-        if (IS_VALID_HANDLE(_E)) {
-            rc = ACR_GET_OS_ERROR();
-            if (rc == EACCES)
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-            else
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, rc);
-            ACR_SET_OS_ERROR(rc);
-        }
+        ACR_THROW_IO_ERRNO();
         return -1;
     }
     rc = acr_ioh_open(m, ACR_DT_MUTEX, 0, mutex_cleanup);
@@ -98,7 +91,7 @@
 
     if (!fname) {
         /* Reinitializing unnamed mutexes is a noop in the Unix code. */
-        ACR_SET_OS_ERROR(ACR_ENOTIMPL);
+        ACR_THROW_IO_IF_ERR(ACR_ENOTIMPL);
         return -1;
     }
     /* res_name_from_filename turns file into a pseudo-name
@@ -109,14 +102,7 @@
 
     m = OpenMutexW(MUTEX_ALL_ACCESS, FALSE, reskey);
     if (!m) {
-        if (IS_VALID_HANDLE(_E)) {
-            rc = ACR_GET_OS_ERROR();
-            if (rc == EACCES)
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-            else
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, rc);
-            ACR_SET_OS_ERROR(rc);
-        }
+        ACR_THROW_IO_ERRNO();
         return -1;
     }
 
@@ -229,3 +215,4 @@
 {
     ACR_UnloadClass(_E, &_clazzn);
 }
+

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/psema.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/psema.c?rev=806092&r1=806091&r2=806092&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/psema.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/psema.c Thu Aug 20 08:59:17 2009
@@ -58,9 +58,7 @@
     wchar_t  keybuf[128];
 
     if (value < 0) {
-        if (IS_VALID_HANDLE(_E))
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, ACR_EINVAL);
-        ACR_SET_OS_ERROR(ACR_EINVAL);
+        ACR_THROW_IO_IF_ERR(ACR_EINVAL);
         return -1;
     }
     if (name == NULL) {
@@ -86,14 +84,7 @@
     sa.bInheritHandle = FALSE;
     s = CreateSemaphoreW(&sa, (LONG)value, (LONG)maxval, reskey);
     if (!s) {
-        if (IS_VALID_HANDLE(_E)) {
-            rc = ACR_GET_OS_ERROR();
-            if (rc == EACCES)
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-            else
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, rc);
-            ACR_SET_OS_ERROR(rc);
-        }
+        ACR_THROW_IO_ERRNO();
         return -1;
     }
     rc = acr_ioh_open(s, ACR_DT_SEMAPHORE, 0, semaphore_cleanup);
@@ -108,10 +99,9 @@
     wchar_t  keybuf[128];
 
     if (name == NULL) {
-        if (IS_VALID_HANDLE(_E))
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, ACR_EINVAL);
+        ACR_THROW_IO_IF_ERR(ACR_EINVAL);
         /* We cannot attach to unnamed semaphore */
-        return ACR_EINVAL;
+        return -1;
     }
     /* Name-based shared memory */
     else {
@@ -124,14 +114,7 @@
 
     s = OpenSemaphoreW(READ_CONTROL | SEMAPHORE_MODIFY_STATE, FALSE, reskey);
     if (!s) {
-        if (IS_VALID_HANDLE(_E)) {
-            rc = ACR_GET_OS_ERROR();
-            if (rc == EACCES)
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-            else
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, rc);
-            ACR_SET_OS_ERROR(rc);
-        }
+        ACR_THROW_IO_ERRNO();
         return -1;
     }
 

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/pshm.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/pshm.c?rev=806092&r1=806091&r2=806092&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/pshm.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/pshm.c Thu Aug 20 08:59:17 2009
@@ -88,12 +88,7 @@
     int rv;
 
     rv = acr_ioh_close(shm);
-    if (rv  && IS_VALID_HANDLE(_E)) {
-        if (ACR_STATUS_IS_EACCES(rv))
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-        else
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, rv);
-    }
+    ACR_THROW_IO_IF_ERR(rv);
     return rv;
 }
 
@@ -102,12 +97,7 @@
     int rc = 0;
     if (!DeleteFileW(filename))
         rc = ACR_GET_OS_ERROR();
-    if (rc  && IS_VALID_HANDLE(_E)) {
-        if (ACR_STATUS_IS_EACCES(rc))
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-        else
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, rc);
-    }
+    ACR_THROW_IO_IF_ERR(rc);
     return rc;
 }
 
@@ -248,13 +238,7 @@
     if (rc) {
         x_free((void *)(shm->filename));
         x_free(shm);
-        if (IS_VALID_HANDLE(_E)) {
-            if (ACR_STATUS_IS_EACCES(rc))
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-            else
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, rc);
-        }
-        ACR_SET_OS_ERROR(rc);
+        ACR_THROW_IO_IF_ERR(rc);
         shm = NULL;
     }
 
@@ -311,13 +295,7 @@
 finally:
     if (rc) {
         x_free(shm);
-        if (IS_VALID_HANDLE(_E)) {
-            if (ACR_STATUS_IS_EACCES(rc))
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-            else
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, rc);
-        }
-        ACR_SET_OS_ERROR(rc);
+        ACR_THROW_IO_IF_ERR(rc);
         shm = NULL;
     }
     if (shm) {
@@ -341,13 +319,9 @@
     m->filename = NULL;
 
     rc = acr_ioh_close(shm);
+
 finally:
-    if (rc && IS_VALID_HANDLE(_E)) {
-        if (ACR_STATUS_IS_EACCES(rc))
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-        else
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, rc);
-    }
+    ACR_THROW_IO_IF_ERR(rc);
     return rc;
 }
 
@@ -363,12 +337,7 @@
     }
 
 finally:
-    if (rc && IS_VALID_HANDLE(_E)) {
-        if (ACR_STATUS_IS_EACCES(rc))
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-        else
-            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, rc);
-    }
+    ACR_THROW_IO_IF_ERR(rc);
     return rc;
 }
 

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/shm.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/shm.c?rev=806092&r1=806091&r2=806092&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/shm.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/shm.c Thu Aug 20 08:59:17 2009
@@ -70,48 +70,40 @@
 ACR_JNI_EXPORT_DECLARE(jobject, SharedMemory, map0)(ACR_JNISTDARGS,
                                                     jobject shmd)
 {
-    jobject mp = NULL;
+    jobject mpo = NULL;
     int sd;
     
     UNREFERENCED_O;
 
     sd = ACR_DescriptorGetInt(_E, shmd);
     if (sd > 0) {
-        char   *mem = (char *)ACR_ShmGetBaseAddr(sd);
         size_t  len;
+        char   *mem = (char *)ACR_ShmGetBaseAddr(sd);
         if (!mem) {
-            int rc = ACR_GET_OS_ERROR();
-            if (ACR_STATUS_IS_EACCES(rc))
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-            else
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, rc);
+            ACR_THROW_IO_ERRNO();
             return NULL;
         }
         len = ACR_ShmGetSize(sd);
-        mp = ACR_NewPointer(_E, mem, len, NULL);
+        mpo = ACR_NewPointer(_E, mem, len, NULL);
     }
-    return mp;
+    return mpo;
 }
 
 ACR_JNI_EXPORT_DECLARE(jobject, SharedMemory, map1)(ACR_JNISTDARGS,
                                                     jobject shmd,
                                                     jlong off, jlong siz)
 {
-    jobject mp = NULL;
+    jobject mpo = NULL;
     int sd;
     
     UNREFERENCED_O;
 
     sd = ACR_DescriptorGetInt(_E, shmd);
     if (sd > 0) {
-        char   *mem = (char *)ACR_ShmGetBaseAddr(sd);
         size_t  len;
+        char   *mem = (char *)ACR_ShmGetBaseAddr(sd);
         if (!mem) {
-            int rc = ACR_GET_OS_ERROR();
-            if (ACR_STATUS_IS_EACCES(rc))
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
-            else
-                ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, rc);
+            ACR_THROW_IO_ERRNO();
             return NULL;
         }
         len = ACR_ShmGetSize(sd);
@@ -119,9 +111,9 @@
             ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINDEX, 0);
             return NULL;
         }
-        mp = ACR_NewPointer(_E, mem + off, (size_t)siz, NULL);
+        mpo = ACR_NewPointer(_E, mem + off, (size_t)siz, NULL);
     }
-    return mp;
+    return mpo;
 }
 
 ACR_JNI_EXPORT_DECLARE(jlong, SharedMemory, size0)(ACR_JNISTDARGS,



Mime
View raw message