PERFORCE change 41614 for review
Robert Watson
rwatson at FreeBSD.org
Fri Nov 7 04:21:11 GMT 2003
http://perforce.freebsd.org/chv.cgi?CH=41614
Change 41614 by rwatson at rwatson_paprika on 2003/11/06 20:20:23
Whitespace and wrap cleanup.
Affected files ...
.. //depot/projects/trustedbsd/mac/sys/kern/sysv_sem.c#16 edit
Differences ...
==== //depot/projects/trustedbsd/mac/sys/kern/sysv_sem.c#16 (text+ko) ====
@@ -41,7 +41,7 @@
#ifdef MAC_DEBUG
#define MPRINTF(a) printf(a)
#else
-#define MPRINTF(a)
+#define MPRINTF(a)
#endif
static void seminit(void);
@@ -49,7 +49,7 @@
static int semunload(void);
static void semexit_myhook(void *arg, struct proc *p);
static int sysctl_sema(SYSCTL_HANDLER_ARGS);
-static int semvalid(int semid, struct semid_kernel *semakptr);
+static int semvalid(int semid, struct semid_kernel *semakptr);
#ifndef _SYS_SYSPROTO_H_
struct __semctl_args;
@@ -73,7 +73,7 @@
static struct mtx sem_mtx; /* semaphore global lock */
static int semtot = 0;
-static struct semid_kernel *sema; /* semaphore id pool */
+static struct semid_kernel *sema; /* semaphore id pool */
static struct mtx *sema_mtx; /* semaphore id pool mutexes*/
static struct sem *sem; /* semaphore pool */
SLIST_HEAD(, sem_undo) semu_list; /* list of active undo structures */
@@ -201,7 +201,7 @@
TUNABLE_INT_FETCH("kern.ipc.semaem", &seminfo.semaem);
sem = malloc(sizeof(struct sem) * seminfo.semmns, M_SEM, M_WAITOK);
- sema = malloc(sizeof(struct semid_kernel ) * seminfo.semmni, M_SEM,
+ sema = malloc(sizeof(struct semid_kernel) * seminfo.semmni, M_SEM,
M_WAITOK);
sema_mtx = malloc(sizeof(struct mtx) * seminfo.semmni, M_SEM,
M_WAITOK | M_ZERO);
@@ -258,7 +258,7 @@
EVENTHANDLER_DEREGISTER(process_exit, semexit_tag);
#ifdef MAC
- for (i = 0; i < seminfo.semmni; i++)
+ for (i = 0; i < seminfo.semmni; i++)
mac_destroy_ipc_sema(&sema[i]);
#endif
free(sem, M_SEM);
@@ -517,7 +517,7 @@
static int
semvalid(semid, semakptr)
int semid;
- struct semid_kernel *semakptr;
+ struct semid_kernel *semakptr;
{
return ((semakptr->u.sem_perm.mode & SEM_ALLOC) == 0 ||
@@ -553,7 +553,7 @@
struct ucred *cred = td->td_ucred;
int i, rval, error;
struct semid_ds sbuf;
- struct semid_kernel *semakptr;
+ struct semid_kernel *semakptr;
struct mtx *sema_mtxp;
u_short usval, count;
@@ -562,7 +562,10 @@
if (!jail_sysvipc_allowed && jailed(td->td_ucred))
return (ENOSYS);
- /* Prevent thread from going any further if module is (being) unloaded */
+ /*
+ * Prevent thread from going any further if module is (being)
+ * unloaded.
+ */
mtx_lock(&refcnt_mtx);
if (refcount < 0 ) {
mtx_unlock(&refcnt_mtx);
@@ -576,7 +579,7 @@
switch(cmd) {
case SEM_STAT:
if (semid < 0 || semid >= seminfo.semmni) {
- error = EINVAL;
+ error = EINVAL;
goto done3;
}
if ((error = copyin(arg, &real_arg, sizeof(real_arg))) != 0)
@@ -591,14 +594,16 @@
if ((error = ipcperm(td, &semakptr->u.sem_perm, IPC_R)))
goto done2;
#ifdef MAC
- if(( error = mac_check_ipc_semctl(cred,semakptr,cmd) )) {
- MPRINTF(("MAC Framework: mac_check_ipc_semctl access denied\n"));
- goto done2;
- }
+ if ((error = mac_check_ipc_semctl(cred, semakptr, cmd))) {
+ MPRINTF((
+ "MAC Framework: mac_check_ipc_semctl access denied\n"));
+ goto done2;
+ }
#endif
mtx_unlock(sema_mtxp);
- error = copyout(&semakptr->u, real_arg.buf, sizeof(struct semid_ds));
- rval = IXSEQ_TO_IPCID(semid,semakptr->u.sem_perm);
+ error = copyout(&semakptr->u, real_arg.buf,
+ sizeof(struct semid_ds));
+ rval = IXSEQ_TO_IPCID(semid, semakptr->u.sem_perm);
if (error == 0)
td->td_retval[0] = rval;
goto done3;
@@ -613,14 +618,15 @@
semakptr = &sema[semid];
sema_mtxp = &sema_mtx[semid];
#ifdef MAC
- mtx_lock(sema_mtxp);
+ mtx_lock(sema_mtxp);
/*
* The MAC framework lets the policies decide what type of access
* is permitted, based on the cmd.
*/
- if(( error = mac_check_ipc_semctl(cred,semakptr,cmd) )) {
- MPRINTF(("MAC Framework: mac_check_ipc_semctl access denied\n"));
- goto done2;
+ if ((error = mac_check_ipc_semctl(cred, semakptr, cmd))) {
+ MPRINTF((
+ "MAC Framework: mac_check_ipc_semctl access denied\n"));
+ goto done2;
}
mtx_unlock(sema_mtxp);
#endif
@@ -668,8 +674,8 @@
goto done2;
semakptr->u.sem_perm.uid = sbuf.sem_perm.uid;
semakptr->u.sem_perm.gid = sbuf.sem_perm.gid;
- semakptr->u.sem_perm.mode = (semakptr->u.sem_perm.mode & ~0777) |
- (sbuf.sem_perm.mode & 0777);
+ semakptr->u.sem_perm.mode = (semakptr->u.sem_perm.mode &
+ ~0777) | (sbuf.sem_perm.mode & 0777);
semakptr->u.sem_ctime = time_second;
break;
@@ -862,7 +868,10 @@
if (!jail_sysvipc_allowed && jailed(td->td_ucred))
return (ENOSYS);
- /* Prevent thread from going any further if module is (being) unloaded */
+ /*
+ * Prevent thread from going any further if module is (being)
+ * unloaded.
+ */
mtx_lock(&refcnt_mtx);
if (refcount < 0 ) {
mtx_unlock(&refcnt_mtx);
@@ -895,16 +904,18 @@
goto done2;
}
#ifdef MAC
- if(( error = mac_check_ipc_semget(cred,&sema[semid]) )) {
- MPRINTF(("MAC Framework: mac_check_ipc_semget access denied\n"));
- goto done2;
+ if ((error = mac_check_ipc_semget(cred,
+ &sema[semid]))) {
+ MPRINTF((
+ "MAC Framework: mac_check_ipc_semget access denied\n"));
+ goto done2;
}
#endif
goto found;
}
}
- DPRINTF(("need to allocate the semid_kernel \n"));
+ DPRINTF(("need to allocate the semid_kernel\n"));
if (key == IPC_PRIVATE || (semflg & IPC_CREAT)) {
if (nsems <= 0 || nsems > seminfo.semmsl) {
DPRINTF(("nsems out of range (0<%d<=%d)\n", nsems,
@@ -924,7 +935,7 @@
break;
}
if (semid == seminfo.semmni) {
- DPRINTF(("no more semid_kernel 's available\n"));
+ DPRINTF(("no more semid_kernel's available\n"));
error = ENOSPC;
goto done2;
}
@@ -947,8 +958,8 @@
#ifdef MAC
mac_create_ipc_sema(cred, &sema[semid]);
#endif
- DPRINTF(("sembase = 0x%x, next = 0x%x\n", sema[semid].u.sem_base,
- &sem[semtot]));
+ DPRINTF(("sembase = 0x%x, next = 0x%x\n",
+ sema[semid].u.sem_base, &sem[semtot]));
} else {
DPRINTF(("didn't find it and wasn't asked to create it\n"));
error = ENOENT;
@@ -984,7 +995,7 @@
int semid = uap->semid;
size_t nsops = uap->nsops;
struct sembuf *sops;
- struct semid_kernel *semakptr;
+ struct semid_kernel *semakptr;
struct sembuf *sopptr = 0;
struct sem *semptr = 0;
struct sem_undo *suptr;
@@ -998,7 +1009,10 @@
if (!jail_sysvipc_allowed && jailed(td->td_ucred))
return (ENOSYS);
- /* Prevent thread from going any further if module is (being) unloaded */
+ /*
+ * Prevent thread from going any further if module is (being)
+ * unloaded
+ */
mtx_lock(&refcnt_mtx);
if (refcount < 0 ) {
mtx_unlock(&refcnt_mtx);
@@ -1064,11 +1078,13 @@
}
#ifdef MAC
/*
- * The MAC hook checks whether the thread has read ( and possibly write)
- * permissions to the semaphore array based on the sopptr->sem_op value.
+ * The MAC hook checks whether the thread has read (and possibly
+ * write) permissions to the semaphore array based on the
+ * sopptr->sem_op value.
*/
if ((error = mac_check_ipc_semop(td->td_ucred, semakptr, j))) {
- MPRINTF(("MAC Framework: mac_check_ipc_semop access denied\n"));
+ MPRINTF((
+ "MAC Framework: mac_check_ipc_semop access denied\n"));
goto done2;
}
#endif
@@ -1310,7 +1326,7 @@
int semid = suptr->un_ent[ix].un_id;
int semnum = suptr->un_ent[ix].un_num;
int adjval = suptr->un_ent[ix].un_adjval;
- struct semid_kernel *semakptr;
+ struct semid_kernel *semakptr;
struct mtx *sema_mtxp;
semakptr = &sema[semid];
@@ -1330,7 +1346,8 @@
semakptr->u.sem_base[semnum].semval));
if (adjval < 0) {
- if (semakptr->u.sem_base[semnum].semval < -adjval)
+ if (semakptr->u.sem_base[semnum].semval <
+ -adjval)
semakptr->u.sem_base[semnum].semval = 0;
else
semakptr->u.sem_base[semnum].semval +=
To Unsubscribe: send mail to majordomo at trustedbsd.org
with "unsubscribe trustedbsd-cvs" in the body of the message
More information about the trustedbsd-cvs
mailing list