add some missing returns, correct args to ipcaccess, general cleanup
authorMike Hibler <hibler@ucbvax.Berkeley.EDU>
Sat, 23 Jun 1990 00:01:58 +0000 (16:01 -0800)
committerMike Hibler <hibler@ucbvax.Berkeley.EDU>
Sat, 23 Jun 1990 00:01:58 +0000 (16:01 -0800)
SCCS-vsn: sys/kern/sysv_shm.c 7.7

usr/src/sys/kern/sysv_shm.c

index 1cfa1a9..f5d3bd9 100644 (file)
@@ -11,7 +11,7 @@
  *
  * from: Utah $Hdr: uipc_shm.c 1.9 89/08/14$
  *
  *
  * from: Utah $Hdr: uipc_shm.c 1.9 89/08/14$
  *
- *     @(#)sysv_shm.c  7.6 (Berkeley) %G%
+ *     @(#)sysv_shm.c  7.7 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
@@ -150,7 +150,7 @@ shmget(p, uap, retval)
                /* XXX: probably not the right thing to do */
                if (shp->shm_perm.mode & SHM_DEST)
                        return (EBUSY);
                /* XXX: probably not the right thing to do */
                if (shp->shm_perm.mode & SHM_DEST)
                        return (EBUSY);
-               if (error = ipcaccess(cred, &shp->shm_perm, uap->shmflg&0777))
+               if (error = ipcaccess(&shp->shm_perm, uap->shmflg&0777, cred))
                        return (error);
                if (uap->size && uap->size > shp->shm_segsz)
                        return (EINVAL);
                        return (error);
                if (uap->size && uap->size > shp->shm_segsz)
                        return (EINVAL);
@@ -158,6 +158,7 @@ shmget(p, uap, retval)
                        return (EEXIST);
        }
        *retval = shp->shm_perm.seq * SHMMMNI + rval;
                        return (EEXIST);
        }
        *retval = shp->shm_perm.seq * SHMMMNI + rval;
+       return (0);
 }
 
 /*
 }
 
 /*
@@ -183,7 +184,7 @@ shmctl(p, uap, retval)
        shp = &shmsegs[uap->shmid % SHMMMNI];
        switch (uap->cmd) {
        case IPC_STAT:
        shp = &shmsegs[uap->shmid % SHMMMNI];
        switch (uap->cmd) {
        case IPC_STAT:
-               if (error = ipcaccess(cred, &shp->shm_perm, IPC_R))
+               if (error = ipcaccess(&shp->shm_perm, IPC_R, cred))
                        return (error);
                return (copyout((caddr_t)shp, uap->buf, sizeof(*shp)));
 
                        return (error);
                return (copyout((caddr_t)shp, uap->buf, sizeof(*shp)));
 
@@ -245,15 +246,15 @@ shmat(p, uap, retval)
        register int size;
        struct mapmem *mp;
        caddr_t uva;
        register int size;
        struct mapmem *mp;
        caddr_t uva;
-       int error, error1, prot, shmmapin();
+       int error, prot, shmmapin();
 
        if (error = shmvalid(uap->shmid))
                return (error);
        shp = &shmsegs[uap->shmid % SHMMMNI];
        if (shp->shm_handle == NULL)
                panic("shmat NULL handle");
 
        if (error = shmvalid(uap->shmid))
                return (error);
        shp = &shmsegs[uap->shmid % SHMMMNI];
        if (shp->shm_handle == NULL)
                panic("shmat NULL handle");
-       if (error = ipcaccess(u.u_cred, &shp->shm_perm,
-                     (uap->shmflg&SHM_RDONLY) ? IPC_R : IPC_R|IPC_W))
+       if (error = ipcaccess(&shp->shm_perm,
+                       (uap->shmflg&SHM_RDONLY) ? IPC_R : IPC_R|IPC_W, u.u_cred))
                return (error);
        uva = uap->shmaddr;
        if (uva && ((int)uva & (SHMLBA-1))) {
                return (error);
        uva = uap->shmaddr;
        if (uva && ((int)uva & (SHMLBA-1))) {
@@ -284,8 +285,7 @@ shmat(p, uap, retval)
        if (error)
                return (error);
        if (error = mmmapin(p, mp, shmmapin)) {
        if (error)
                return (error);
        if (error = mmmapin(p, mp, shmmapin)) {
-               if (error1 = mmfree(p, mp))
-                       return (error1);
+               (void) mmfree(p, mp);
                return (error);
        }
        /*
                return (error);
        }
        /*
@@ -295,6 +295,7 @@ shmat(p, uap, retval)
        shp->shm_atime = time.tv_sec;
        shp->shm_nattch++;
        *retval = (int) uva;
        shp->shm_atime = time.tv_sec;
        shp->shm_nattch++;
        *retval = (int) uva;
+       return (0);
 }
 
 /*
 }
 
 /*
@@ -344,10 +345,10 @@ shmfork(mp, ischild)
 /*
  * Detach from shared memory segment on exit (or exec)
  */
 /*
  * Detach from shared memory segment on exit (or exec)
  */
-shmexit(p, mp)
-       struct proc *p;
+shmexit(mp)
        struct mapmem *mp;
 {
        struct mapmem *mp;
 {
+       struct proc *p = u.u_procp;             /* XXX */
 
        return (shmufree(p, mp));
 }
 
        return (shmufree(p, mp));
 }