Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 Jun 2006 14:05:36 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 100287 for review
Message-ID:  <200606291405.k5TE5aIj067614@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=100287

Change 100287 by jhb@jhb_mutex on 2006/06/29 14:05:23

	IFC @100285.

Affected files ...

.. //depot/projects/smpng/sys/kern/sysv_sem.c#38 integrate

Differences ...

==== //depot/projects/smpng/sys/kern/sysv_sem.c#38 (text+ko) ====

@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/sysv_sem.c,v 1.80 2006/06/27 18:28:50 jhb Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/sysv_sem.c,v 1.81 2006/06/29 13:58:36 jhb Exp $");
 
 #include "opt_sysvipc.h"
 #include "opt_mac.h"
@@ -591,6 +591,7 @@
 	struct semid_kernel *semakptr;
 	struct mtx *sema_mtxp;
 	u_short usval, count;
+	int semidx;
 
 	DPRINTF(("call to semctl(%d, %d, %d, 0x%x)\n",
 	    semid, semnum, cmd, arg));
@@ -601,6 +602,10 @@
 
 	switch(cmd) {
 	case SEM_STAT:
+		/*
+		 * For this command we assume semid is an array index
+		 * rather than an IPC id.
+		 */
 		if (semid < 0 || semid >= seminfo.semmni)
 			return (EINVAL);
 		semakptr = &sema[semid];
@@ -632,12 +637,12 @@
 		return (error);
 	}
 
-	semid = IPCID_TO_IX(semid);
-	if (semid < 0 || semid >= seminfo.semmni)
+	semidx = IPCID_TO_IX(semid);
+	if (semidx < 0 || semidx >= seminfo.semmni)
 		return (EINVAL);
 
-	semakptr = &sema[semid];
-	sema_mtxp = &sema_mtx[semid];
+	semakptr = &sema[semidx];
+	sema_mtxp = &sema_mtx[semidx];
 #ifdef MAC
 	mtx_lock(sema_mtxp);
 	error = mac_check_sysv_semctl(cred, semakptr, cmd);
@@ -674,7 +679,7 @@
 		mac_cleanup_sysv_sem(semakptr);
 #endif
 		SEMUNDO_LOCK();
-		semundo_clear(semid, -1);
+		semundo_clear(semidx, -1);
 		SEMUNDO_UNLOCK();
 		wakeup(semakptr);
 		break;
@@ -804,7 +809,7 @@
 		}
 		semakptr->u.sem_base[semnum].semval = arg->val;
 		SEMUNDO_LOCK();
-		semundo_clear(semid, semnum);
+		semundo_clear(semidx, semnum);
 		SEMUNDO_UNLOCK();
 		wakeup(semakptr);
 		break;
@@ -847,7 +852,7 @@
 			semakptr->u.sem_base[i].semval = usval;
 		}
 		SEMUNDO_LOCK();
-		semundo_clear(semid, -1);
+		semundo_clear(semidx, -1);
 		SEMUNDO_UNLOCK();
 		wakeup(semakptr);
 		break;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200606291405.k5TE5aIj067614>