You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/08/14 17:25:32 UTC
svn commit: r804258 - in /commons/sandbox/runtime/trunk/src/main/native/os:
hpux/shm.c unix/pmutex.c unix/shm.c win32/group.c win32/shm.c win32/user.c
Author: mturk
Date: Fri Aug 14 15:25:28 2009
New Revision: 804258
URL: http://svn.apache.org/viewvc?rev=804258&view=rev
Log:
Rename cleanu goto with finally
Modified:
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/group.c
commons/sandbox/runtime/trunk/src/main/native/os/win32/shm.c
commons/sandbox/runtime/trunk/src/main/native/os/win32/user.c
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=804258&r1=804257&r2=804258&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 Fri Aug 14 15:25:28 2009
@@ -79,11 +79,11 @@
*/
if (shmctl(m->shmid, IPC_RMID, NULL) == -1 && errno != EINVAL) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
if (shmdt(m->base) == -1) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
if (access(m->filename, F_OK)) {
rc = ACR_SUCCESS;
@@ -93,7 +93,7 @@
rc = ACR_GET_OS_ERROR();
}
}
-cleanup:
+finally:
x_free((void *)(m->filename));
free(m);
return rc;
@@ -151,7 +151,7 @@
file = open(filename, O_WRONLY);
if (file < 0) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
/* ftok() (on solaris at least) requires that the file actually
@@ -161,13 +161,13 @@
if (shmkey == (key_t)-1) {
rc = ACR_GET_OS_ERROR();
close(file);
- goto cleanup;
+ goto finally;
}
close(file);
if ((shmid = shmget(shmkey, 0, SHM_R | SHM_W)) < 0) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
/* Indicate that the segment is to be destroyed as soon
@@ -176,10 +176,10 @@
*/
if (shmctl(shmid, IPC_RMID, NULL) == -1) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
-cleanup:
+finally:
unlink(filename);
if (rc && !IS_INVALID_HANDLE(_E)) {
if (rc == EACCES)
@@ -275,7 +275,7 @@
file = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0660);
if (file < 0) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
/* ftok() (on solaris at least) requires that the file actually
@@ -283,30 +283,30 @@
shm->shmkey = ftok(filename, 1);
if (shm->shmkey == (key_t)-1) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
if ((shm->shmid = shmget(shm->shmkey, shm->realsize,
SHM_R | SHM_W | IPC_CREAT | IPC_EXCL)) < 0) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
if ((shm->base = shmat(shm->shmid, NULL, 0)) == (void *)-1) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
shm->usable = shm->base;
if (shmctl(shm->shmid, IPC_STAT, &shmbuf) == -1) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
shmbuf.shm_perm.uid = getuid();
shmbuf.shm_perm.gid = getgid();
if (shmctl(shm->shmid, IPC_SET, &shmbuf) == -1) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
nbytes = sizeof(memblock_t);
@@ -319,9 +319,9 @@
} while (rc == (acr_size_t)-1 && errno == EINTR);
if (rc == -1) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
-cleanup:
+finally:
if (file > 0)
rc = close(file);
if (rc) {
@@ -372,7 +372,7 @@
file = open(filename, O_RDONLY);
if (file < 0) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
nbytes = sizeof(memblock_t);
@@ -384,35 +384,35 @@
/* Wrong format */
rc = EBADF;
close(file);
- goto cleanup;
+ goto finally;
}
rc = close(file);
if (rc) {
- goto cleanup;
+ goto finally;
}
if (hdr.magic != ACR_SHM_MAGIC) {
/* Not created by us or corrupted */
rc = ACR_EBADF;
- goto cleanup;
+ goto finally;
}
shm->reqsize = hdr.size;
shm->shmkey = ftok(filename, 1);
if (shm->shmkey == (key_t)-1) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
if ((shm->shmid = shmget(shm->shmkey, 0, SHM_R | SHM_W)) == -1) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
if ((shm->base = shmat(shm->shmid, NULL, 0)) == (void *)-1) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
shm->usable = shm->base;
shm->realsize = shm->reqsize;
-cleanup:
+finally:
if (rc) {
free((void *)(shm->filename));
free(shm);
@@ -440,13 +440,13 @@
if (IS_INVALID_HANDLE(m) || ACR_IOH_TYPE(shm) != ACR_DT_SHM) {
rc = ACR_EINVAL;
- goto cleanup;
+ goto finally;
}
x_free((void *)(m->filename));
m->filename = NULL;
rc = acr_ioh_close(shm);
-cleanup:
+finally:
if (rc && !IS_INVALID_HANDLE(_E)) {
if (rc == EACCES)
ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
@@ -466,21 +466,21 @@
if (IS_INVALID_HANDLE(m) || ACR_IOH_TYPE(shm) != ACR_DT_SHM) {
rc = ACR_EINVAL;
- goto cleanup;
+ goto finally;
}
if ((shmid = shmget(m->shmkey, 0, SHM_R | SHM_W)) == -1) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
shmbuf.shm_perm.uid = uid;
shmbuf.shm_perm.gid = gid;
shmbuf.shm_perm.mode = ACR_UnixPermsToMode(perms);
if (shmctl(shmid, IPC_SET, &shmbuf) == -1) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
-cleanup:
+finally:
if (rc && !IS_INVALID_HANDLE(_E)) {
if (rc == EACCES)
ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
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=804258&r1=804257&r2=804258&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 Fri Aug 14 15:25:28 2009
@@ -66,16 +66,16 @@
if (m->filedes < 0) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
ick.val = 1;
if (semctl(m->filedes, 0, SETVAL, ick) < 0) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
m->locked = 0;
-cleanup:
+finally:
if (rc) {
if (m->filedes > 0) {
ick.val = 0;
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=804258&r1=804257&r2=804258&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 Fri Aug 14 15:25:28 2009
@@ -79,11 +79,11 @@
*/
if (shmctl(m->shmid, IPC_RMID, NULL) == -1 && errno != EINVAL) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
if (shmdt(m->base) == -1) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
if (access(m->filename, F_OK)) {
rc = ACR_SUCCESS;
@@ -93,7 +93,7 @@
rc = ACR_GET_OS_ERROR();
}
}
-cleanup:
+finally:
x_free((void *)(m->filename));
free(m);
return rc;
@@ -151,7 +151,7 @@
file = open(filename, O_WRONLY);
if (file < 0) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
/* ftok() (on solaris at least) requires that the file actually
@@ -161,13 +161,13 @@
if (shmkey == (key_t)-1) {
rc = ACR_GET_OS_ERROR();
close(file);
- goto cleanup;
+ goto finally;
}
close(file);
if ((shmid = shmget(shmkey, 0, SHM_R | SHM_W)) < 0) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
/* Indicate that the segment is to be destroyed as soon
@@ -176,10 +176,10 @@
*/
if (shmctl(shmid, IPC_RMID, NULL) == -1) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
-cleanup:
+finally:
unlink(filename);
if (rc && !IS_INVALID_HANDLE(_E)) {
if (rc == EACCES)
@@ -256,7 +256,7 @@
file = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0660);
if (file < 0) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
/* ftok() (on solaris at least) requires that the file actually
@@ -264,30 +264,30 @@
shm->shmkey = ftok(filename, 1);
if (shm->shmkey == (key_t)-1) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
if ((shm->shmid = shmget(shm->shmkey, shm->realsize,
SHM_R | SHM_W | IPC_CREAT | IPC_EXCL)) < 0) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
if ((shm->base = shmat(shm->shmid, NULL, 0)) == (void *)-1) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
shm->usable = shm->base;
if (shmctl(shm->shmid, IPC_STAT, &shmbuf) == -1) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
shmbuf.shm_perm.uid = getuid();
shmbuf.shm_perm.gid = getgid();
if (shmctl(shm->shmid, IPC_SET, &shmbuf) == -1) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
nbytes = sizeof(memblock_t);
@@ -300,9 +300,9 @@
} while (rc == (acr_size_t)-1 && errno == EINTR);
if (rc == -1) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
-cleanup:
+finally:
if (file > 0)
rc = close(file);
if (rc) {
@@ -353,7 +353,7 @@
file = open(filename, O_RDONLY);
if (file < 0) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
nbytes = sizeof(memblock_t);
@@ -365,35 +365,35 @@
/* Wrong format */
rc = EBADF;
close(file);
- goto cleanup;
+ goto finally;
}
rc = close(file);
if (rc) {
- goto cleanup;
+ goto finally;
}
if (hdr.magic != ACR_SHM_MAGIC) {
/* Not created by us or corrupted */
rc = ACR_EBADF;
- goto cleanup;
+ goto finally;
}
shm->reqsize = hdr.size;
shm->shmkey = ftok(filename, 1);
if (shm->shmkey == (key_t)-1) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
if ((shm->shmid = shmget(shm->shmkey, 0, SHM_R | SHM_W)) == -1) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
if ((shm->base = shmat(shm->shmid, NULL, 0)) == (void *)-1) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
shm->usable = shm->base;
shm->realsize = shm->reqsize;
-cleanup:
+finally:
if (rc) {
free((void *)(shm->filename));
free(shm);
@@ -421,13 +421,13 @@
if (IS_INVALID_HANDLE(m) || ACR_IOH_TYPE(shm) != ACR_DT_SHM) {
rc = ACR_EINVAL;
- goto cleanup;
+ goto finally;
}
x_free((void *)(m->filename));
m->filename = NULL;
rc = acr_ioh_close(shm);
-cleanup:
+finally:
if (rc && !IS_INVALID_HANDLE(_E)) {
if (rc == EACCES)
ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
@@ -447,21 +447,21 @@
if (IS_INVALID_HANDLE(m) || ACR_IOH_TYPE(shm) != ACR_DT_SHM) {
rc = ACR_EINVAL;
- goto cleanup;
+ goto finally;
}
if ((shmid = shmget(m->shmkey, 0, SHM_R | SHM_W)) == -1) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
shmbuf.shm_perm.uid = uid;
shmbuf.shm_perm.gid = gid;
shmbuf.shm_perm.mode = ACR_UnixPermsToMode(perms);
if (shmctl(shmid, IPC_SET, &shmbuf) == -1) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
-cleanup:
+finally:
if (rc && !IS_INVALID_HANDLE(_E)) {
if (rc == EACCES)
ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/group.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/group.c?rev=804258&r1=804257&r2=804258&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/group.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/group.c Fri Aug 14 15:25:28 2009
@@ -294,19 +294,19 @@
if (!gid) {
grp = ACR_GetTokenInformation(_E, token, TokenGroups);
if (!grp) {
- goto cleanup;
+ goto finally;
}
for (i = 0; i < grp->GroupCount; i++) {
if (grp->Groups[i].Attributes & SE_GROUP_OWNER) {
gid = ACR_GroupObjectCreateFromId(_E, grp->Groups[i].Sid);
if (!gid) {
- goto cleanup;
+ goto finally;
}
break;
}
}
}
-cleanup:
+finally:
if (grp)
free(grp);
CloseHandle(token);
@@ -357,7 +357,7 @@
if ((*_E)->ExceptionCheck(_E) || gid == NULL) {
NetApiBufferFree(pb);
grps = NULL;
- goto cleanup;
+ goto finally;
}
(*_E)->SetObjectArrayElement(_E, grps, j, gid);
(*_E)->DeleteLocalRef(_E, gid);
@@ -368,7 +368,7 @@
}
} while (res == ERROR_MORE_DATA);
-cleanup:
+finally:
return grps;
}
@@ -406,7 +406,7 @@
if ((*_E)->ExceptionCheck(_E) || gid == NULL) {
NetApiBufferFree(pb);
grps = NULL;
- goto cleanup;
+ goto finally;
}
/* Update isLocal filed to false */
SET_IFIELD_Z(0003, gid, JNI_FALSE);
@@ -419,7 +419,7 @@
}
} while (res == ERROR_MORE_DATA);
-cleanup:
+finally:
return grps;
}
@@ -478,7 +478,7 @@
if ((*_E)->ExceptionCheck(_E) || gid == NULL) {
NetApiBufferFree(pb);
usrs = NULL;
- goto cleanup;
+ goto finally;
}
(*_E)->SetObjectArrayElement(_E, usrs, j, uid);
(*_E)->DeleteLocalRef(_E, uid);
@@ -489,7 +489,7 @@
}
} while (res == ERROR_MORE_DATA);
-cleanup:
+finally:
return usrs;
}
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=804258&r1=804257&r2=804258&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 Fri Aug 14 15:25:28 2009
@@ -157,13 +157,13 @@
NULL);
if (hfile == INVALID_HANDLE_VALUE) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
if (SetFilePointer(hfile, sizelo, lpdwhi, FILE_BEGIN) == INVALID_SET_FILE_POINTER) {
rc = ACR_GET_OS_ERROR();
if (rc) {
CloseHandle(hfile);
- goto cleanup;
+ goto finally;
}
}
/* res_name_from_filename turns file into a pseudo-name
@@ -183,17 +183,17 @@
if (hmap && rc == ERROR_ALREADY_EXISTS) {
CloseHandle(hmap);
rc = ACR_EEXIST;
- goto cleanup;
+ goto finally;
}
if (!hmap) {
- goto cleanup;
+ goto finally;
}
base = MapViewOfFile(hmap, FILE_MAP_READ | FILE_MAP_WRITE,
0, 0, nbytes);
if (!base) {
rc = ACR_GET_OS_ERROR();
CloseHandle(hmap);
- goto cleanup;
+ goto finally;
}
shm->hmap = hmap;
shm->memblk = base;
@@ -210,13 +210,13 @@
shm->filename = ACR_StrdupW(_E, THROW_FMARK, filename);
if (!shm->filename) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
}
else
shm->filename = NULL;
-cleanup:
+finally:
if (rc) {
x_free((void *)(shm->filename));
x_free(shm);
@@ -260,13 +260,13 @@
hmap = OpenFileMappingW(FILE_MAP_READ | FILE_MAP_WRITE, FALSE, reskey);
if (!hmap) {
rc = ACR_GET_OS_ERROR();
- goto cleanup;
+ goto finally;
}
base = MapViewOfFile(hmap, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0);
if (!base) {
rc = ACR_GET_OS_ERROR();
CloseHandle(hmap);
- goto cleanup;
+ goto finally;
}
shm->memblk = base;
/* Real shm->mem->size could be recovered with VirtualQuery */
@@ -276,7 +276,7 @@
shm->usrmem = (char*)base + sizeof(memblock_t);
shm->filename = NULL;
-cleanup:
+finally:
if (rc) {
free(shm);
if (!IS_INVALID_HANDLE(_E)) {
@@ -303,13 +303,13 @@
if (IS_INVALID_HANDLE(m) || ACR_IOH_TYPE(shm) != ACR_DT_SHM) {
rc = ACR_EINVAL;
- goto cleanup;
+ goto finally;
}
x_free((void *)(m->filename));
m->filename = NULL;
rc = acr_ioh_close(shm);
-cleanup:
+finally:
if (rc && !IS_INVALID_HANDLE(_E)) {
if (rv == EACCES)
ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
@@ -327,10 +327,10 @@
if (IS_INVALID_HANDLE(m) || ACR_IOH_TYPE(shm) != ACR_DT_SHM) {
rc = ACR_EINVAL;
- goto cleanup;
+ goto finally;
}
-cleanup:
+finally:
if (rc && !IS_INVALID_HANDLE(_E)) {
if (rc == EACCES)
ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0);
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/user.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/user.c?rev=804258&r1=804257&r2=804258&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/user.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/user.c Fri Aug 14 15:25:28 2009
@@ -374,7 +374,7 @@
if ((*_E)->ExceptionCheck(_E) || uid == NULL) {
NetApiBufferFree(pb);
usrs = NULL;
- goto cleanup;
+ goto finally;
}
(*_E)->SetObjectArrayElement(_E, usrs, j, uid);
(*_E)->DeleteLocalRef(_E, uid);
@@ -385,7 +385,7 @@
}
} while (res == ERROR_MORE_DATA);
-cleanup:
+finally:
return usrs;
}
@@ -430,7 +430,7 @@
if ((*_E)->ExceptionCheck(_E) || uid == NULL) {
NetApiBufferFree(pb);
usrs = NULL;
- goto cleanup;
+ goto finally;
}
(*_E)->SetObjectArrayElement(_E, usrs, j, uid);
(*_E)->DeleteLocalRef(_E, uid);
@@ -441,7 +441,8 @@
}
} while (res == ERROR_MORE_DATA);
-cleanup:
+finally:
return usrs;
}
+