commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r805897 - in /commons/sandbox/runtime/trunk/src/main/native/os: darwin/pmutex.c hpux/shm.c unix/pmutex.c unix/shm.c win32/pmutex.c win32/psema.c win32/shm.c
Date Wed, 19 Aug 2009 17:25:11 GMT
Author: mturk
Date: Wed Aug 19 17:25:11 2009
New Revision: 805897

URL: http://svn.apache.org/viewvc?rev=805897&view=rev
Log:
Use VALID_HANDLE macro

Modified:
    commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c
    commons/sandbox/runtime/trunk/src/main/native/os/hpux/shm.c
    commons/sandbox/runtime/trunk/src/main/native/os/unix/pmutex.c
    commons/sandbox/runtime/trunk/src/main/native/os/unix/shm.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/shm.c

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=805897&r1=805896&r2=805897&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 Wed Aug 19 17:25:11 2009
@@ -109,7 +109,7 @@
     if (rc) {
         free(m->fname);
         free(m);
-        if (!IS_INVALID_HANDLE(_E)) {
+        if (IS_VALID_HANDLE(_E)) {
             if (ACR_STATUS_IS_EACCES(rc))
                 ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
             else

Modified: commons/sandbox/runtime/trunk/src/main/native/os/hpux/shm.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/hpux/shm.c?rev=805897&r1=805896&r2=805897&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/hpux/shm.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/hpux/shm.c Wed Aug 19 17:25:11 2009
@@ -143,7 +143,7 @@
     int rv;
 
     rv = acr_ioh_close(shm);
-    if (rv  && !IS_INVALID_HANDLE(_E)) {
+    if (rv  && IS_VALID_HANDLE(_E)) {
         if (rv == EACCES)
             ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
         else
@@ -195,7 +195,7 @@
 
 finally:
     unlink(filename);
-    if (rc  && !IS_INVALID_HANDLE(_E)) {
+    if (rc  && IS_VALID_HANDLE(_E)) {
         if (rc == EACCES)
             ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
         else
@@ -216,7 +216,7 @@
 
     if (reqsize > ACR_SIZE_T_MAX) {
         /* Guard against insane sizes */
-        if (!IS_INVALID_HANDLE(_E)) {
+        if (IS_VALID_HANDLE(_E)) {
             ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINVAL, 0);
         }
         ACR_SET_OS_ERROR(ACR_EINVAL);
@@ -260,7 +260,7 @@
 anonerr:
         if (rc) {
             free(shm);
-            if (!IS_INVALID_HANDLE(_E)) {
+            if (IS_VALID_HANDLE(_E)) {
                 if (rc == EACCES)
                     ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
                 else
@@ -341,7 +341,7 @@
         if (rc) {
             free((void *)(shm->filename));
             free(shm);
-            if (!IS_INVALID_HANDLE(_E)) {
+            if (IS_VALID_HANDLE(_E)) {
                 if (rc == EACCES)
                     ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
                 else
@@ -430,7 +430,7 @@
     if (rc) {
         free((void *)(shm->filename));
         free(shm);
-        if (!IS_INVALID_HANDLE(_E)) {
+        if (IS_VALID_HANDLE(_E)) {
             if (rc == EACCES)
                 ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
             else
@@ -461,7 +461,7 @@
 
     rc = acr_ioh_close(shm);
 finally:
-    if (rc  && !IS_INVALID_HANDLE(_E)) {
+    if (rc  && IS_VALID_HANDLE(_E)) {
         if (rc == EACCES)
             ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
         else
@@ -495,7 +495,7 @@
     }
 
 finally:
-    if (rc && !IS_INVALID_HANDLE(_E)) {
+    if (rc && IS_VALID_HANDLE(_E)) {
         if (rc == EACCES)
             ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
         else

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=805897&r1=805896&r2=805897&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 Wed Aug 19 17:25:11 2009
@@ -96,7 +96,7 @@
             semctl(m->filedes, 0, IPC_RMID, ick);
         }
         free(m);
-        if (!IS_INVALID_HANDLE(_E)) {
+        if (IS_VALID_HANDLE(_E)) {
             if (ACR_STATUS_IS_EACCES(rc))
                 ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
             else

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/shm.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/shm.c?rev=805897&r1=805896&r2=805897&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/shm.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/shm.c Wed Aug 19 17:25:11 2009
@@ -143,7 +143,7 @@
     int rv;
 
     rv = acr_ioh_close(shm);
-    if (rv  && !IS_INVALID_HANDLE(_E)) {
+    if (rv  && IS_VALID_HANDLE(_E)) {
         if (rv == EACCES)
             ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
         else
@@ -195,7 +195,7 @@
 
 finally:
     unlink(filename);
-    if (rc  && !IS_INVALID_HANDLE(_E)) {
+    if (rc  && IS_VALID_HANDLE(_E)) {
         if (ACR_STATUS_IS_EACCES(rc))
             ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
         else
@@ -216,7 +216,7 @@
 
     if (reqsize > ACR_SIZE_T_MAX) {
         /* Guard against insane sizes */
-        if (!IS_INVALID_HANDLE(_E)) {
+        if (IS_VALID_HANDLE(_E)) {
             ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINVAL, 0);
         }
         ACR_SET_OS_ERROR(ACR_EINVAL);
@@ -236,7 +236,7 @@
         if (shm->base == (void *)MAP_FAILED) {
             rc =  ACR_GET_OS_ERROR();
             free(shm);
-            if (!IS_INVALID_HANDLE(_E)) {
+            if (IS_VALID_HANDLE(_E)) {
                 if (ACR_STATUS_IS_EACCES(rc))
                     ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
                 else
@@ -322,7 +322,7 @@
         if (rc) {
             free((void *)(shm->filename));
             free(shm);
-            if (!IS_INVALID_HANDLE(_E)) {
+            if (IS_VALID_HANDLE(_E)) {
                 if (ACR_STATUS_IS_EACCES(rc))
                     ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
                 else
@@ -411,7 +411,7 @@
     if (rc) {
         free((void *)(shm->filename));
         free(shm);
-        if (!IS_INVALID_HANDLE(_E)) {
+        if (IS_VALID_HANDLE(_E)) {
             if (ACR_STATUS_IS_EACCES(rc))
                 ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
             else
@@ -442,7 +442,7 @@
 
     rc = acr_ioh_close(shm);
 finally:
-    if (rc  && !IS_INVALID_HANDLE(_E)) {
+    if (rc  && IS_VALID_HANDLE(_E)) {
         if (ACR_STATUS_IS_EACCES(rc))
             ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
         else
@@ -476,7 +476,7 @@
     }
 
 finally:
-    if (rc && !IS_INVALID_HANDLE(_E)) {
+    if (rc && IS_VALID_HANDLE(_E)) {
         if (ACR_STATUS_IS_EACCES(rc))
             ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
         else

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=805897&r1=805896&r2=805897&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 Wed Aug 19 17:25:11 2009
@@ -40,7 +40,7 @@
 static int mutex_cleanup(void *mutex, int type, unsigned int flags)
 {
     if (type == ACR_DT_MUTEX) {
-        if (!IS_INVALID_HANDLE(mutex))
+        if (IS_VALID_HANDLE(mutex))
             CloseHandle(mutex);
         return ACR_SUCCESS;
     }
@@ -76,7 +76,7 @@
     sa.bInheritHandle = FALSE;
     m = CreateMutexW(&sa, FALSE, reskey);
     if (!m) {
-        if (!IS_INVALID_HANDLE(_E)) {
+        if (IS_VALID_HANDLE(_E)) {
             rc = ACR_GET_OS_ERROR();
             if (rc == EACCES)
                 ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
@@ -109,7 +109,7 @@
 
     m = OpenMutexW(MUTEX_ALL_ACCESS, FALSE, reskey);
     if (!m) {
-        if (!IS_INVALID_HANDLE(_E)) {
+        if (IS_VALID_HANDLE(_E)) {
             rc = ACR_GET_OS_ERROR();
             if (rc == EACCES)
                 ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);

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=805897&r1=805896&r2=805897&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 Wed Aug 19 17:25:11 2009
@@ -40,7 +40,7 @@
 static int semaphore_cleanup(void *sema, int type, unsigned int flags)
 {
     if (type == ACR_DT_SEMAPHORE) {
-        if (!IS_INVALID_HANDLE(sema))
+        if (IS_VALID_HANDLE(sema))
             CloseHandle(sema);
         return ACR_SUCCESS;
     }
@@ -58,6 +58,8 @@
     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);
         return -1;
     }
@@ -84,7 +86,7 @@
     sa.bInheritHandle = FALSE;
     s = CreateSemaphoreW(&sa, (LONG)value, (LONG)maxval, reskey);
     if (!s) {
-        if (!IS_INVALID_HANDLE(_E)) {
+        if (IS_VALID_HANDLE(_E)) {
             rc = ACR_GET_OS_ERROR();
             if (rc == EACCES)
                 ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
@@ -106,6 +108,8 @@
     wchar_t  keybuf[128];
 
     if (name == NULL) {
+        if (IS_VALID_HANDLE(_E))
+            ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EIO, ACR_EINVAL);
         /* We cannot attach to unnamed semaphore */
         return ACR_EINVAL;
     }
@@ -120,7 +124,7 @@
 
     s = OpenSemaphoreW(READ_CONTROL | SEMAPHORE_MODIFY_STATE, FALSE, reskey);
     if (!s) {
-        if (!IS_INVALID_HANDLE(_E)) {
+        if (IS_VALID_HANDLE(_E)) {
             rc = ACR_GET_OS_ERROR();
             if (rc == EACCES)
                 ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/shm.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/shm.c?rev=805897&r1=805896&r2=805897&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/shm.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/shm.c Wed Aug 19 17:25:11 2009
@@ -88,7 +88,7 @@
     int rv;
 
     rv = acr_ioh_close(shm);
-    if (rv  && !IS_INVALID_HANDLE(_E)) {
+    if (rv  && IS_VALID_HANDLE(_E)) {
         if (rv == EACCES)
             ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
         else
@@ -122,7 +122,7 @@
 
     if (reqsize > ACR_SIZE_T_MAX) {
         /* Guard against insane sizes */
-        if (!IS_INVALID_HANDLE(_E)) {
+        if (IS_VALID_HANDLE(_E)) {
             ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINVAL, 0);
         }
         ACR_SET_OS_ERROR(ACR_EINVAL);
@@ -242,7 +242,7 @@
     if (rc) {
         x_free((void *)(shm->filename));
         x_free(shm);
-        if (!IS_INVALID_HANDLE(_E)) {
+        if (IS_VALID_HANDLE(_E)) {
             if (rc == EACCES)
                 ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
             else
@@ -271,8 +271,8 @@
     int        pagefile = 0;
 
     if (!filename) {
-        ACR_SET_OS_ERROR(ACR_EINVAL);
-        return -1;
+        rc = ACR_EINVAL;
+        goto finally;
     }
     shm = ACR_Calloc(_E, THROW_FMARK, sizeof(acr_shm_t));
     if (!shm)
@@ -304,8 +304,8 @@
 
 finally:
     if (rc) {
-        free(shm);
-        if (!IS_INVALID_HANDLE(_E)) {
+        x_free(shm);
+        if (IS_VALID_HANDLE(_E)) {
             if (ACR_STATUS_IS_EACCES(rc))
                 ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
             else
@@ -336,7 +336,7 @@
 
     rc = acr_ioh_close(shm);
 finally:
-    if (rc && !IS_INVALID_HANDLE(_E)) {
+    if (rc && IS_VALID_HANDLE(_E)) {
         if (ACR_STATUS_IS_EACCES(rc))
             ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
         else
@@ -357,7 +357,7 @@
     }
 
 finally:
-    if (rc && !IS_INVALID_HANDLE(_E)) {
+    if (rc && IS_VALID_HANDLE(_E)) {
         if (ACR_STATUS_IS_EACCES(rc))
             ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
         else



Mime
View raw message