sysvshm: fix up some whitespace issues and spurious initialisation

This commit is contained in:
Mateusz Guzik 2015-07-02 19:14:30 +00:00
parent 77a26248a3
commit e2f5418e73

View File

@ -216,7 +216,7 @@ shm_find_segment(int arg, bool is_shmid)
shmseg = &shmsegs[segnum]; shmseg = &shmsegs[segnum];
if ((shmseg->u.shm_perm.mode & SHMSEG_ALLOCATED) == 0 || if ((shmseg->u.shm_perm.mode & SHMSEG_ALLOCATED) == 0 ||
(!shm_allow_removed && (!shm_allow_removed &&
(shmseg->u.shm_perm.mode & SHMSEG_REMOVED) != 0) || (shmseg->u.shm_perm.mode & SHMSEG_REMOVED) != 0) ||
(is_shmid && shmseg->u.shm_perm.seq != IPCID_TO_SEQ(arg))) (is_shmid && shmseg->u.shm_perm.seq != IPCID_TO_SEQ(arg)))
return (NULL); return (NULL);
return (shmseg); return (shmseg);
@ -278,8 +278,9 @@ kern_shmdt_locked(struct thread *td, const void *shmaddr)
struct shmmap_state *shmmap_s; struct shmmap_state *shmmap_s;
#ifdef MAC #ifdef MAC
struct shmid_kernel *shmsegptr; struct shmid_kernel *shmsegptr;
int error;
#endif #endif
int error, i; int i;
SYSVSHM_ASSERT_LOCKED(); SYSVSHM_ASSERT_LOCKED();
if (!prison_allow(td->td_ucred, PR_ALLOW_SYSVIPC)) if (!prison_allow(td->td_ucred, PR_ALLOW_SYSVIPC))
@ -301,8 +302,7 @@ kern_shmdt_locked(struct thread *td, const void *shmaddr)
if (error != 0) if (error != 0)
return (error); return (error);
#endif #endif
error = shm_delete_mapping(p->p_vmspace, shmmap_s); return (shm_delete_mapping(p->p_vmspace, shmmap_s));
return (error);
} }
#ifndef _SYS_SYSPROTO_H_ #ifndef _SYS_SYSPROTO_H_
@ -441,7 +441,6 @@ kern_shmctl_locked(struct thread *td, int shmid, int cmd, void *buf,
if (!prison_allow(td->td_ucred, PR_ALLOW_SYSVIPC)) if (!prison_allow(td->td_ucred, PR_ALLOW_SYSVIPC))
return (ENOSYS); return (ENOSYS);
error = 0;
switch (cmd) { switch (cmd) {
/* /*
* It is possible that kern_shmctl is being called from the Linux ABI * It is possible that kern_shmctl is being called from the Linux ABI
@ -550,10 +549,10 @@ struct shmctl_args {
int int
sys_shmctl(struct thread *td, struct shmctl_args *uap) sys_shmctl(struct thread *td, struct shmctl_args *uap)
{ {
int error = 0; int error;
struct shmid_ds buf; struct shmid_ds buf;
size_t bufsz; size_t bufsz;
/* /*
* The only reason IPC_INFO, SHM_INFO, SHM_STAT exists is to support * The only reason IPC_INFO, SHM_INFO, SHM_STAT exists is to support
* Linux binaries. If we see the call come through the FreeBSD ABI, * Linux binaries. If we see the call come through the FreeBSD ABI,
@ -568,11 +567,11 @@ sys_shmctl(struct thread *td, struct shmctl_args *uap)
if ((error = copyin(uap->buf, &buf, sizeof(struct shmid_ds)))) if ((error = copyin(uap->buf, &buf, sizeof(struct shmid_ds))))
goto done; goto done;
} }
error = kern_shmctl(td, uap->shmid, uap->cmd, (void *)&buf, &bufsz); error = kern_shmctl(td, uap->shmid, uap->cmd, (void *)&buf, &bufsz);
if (error) if (error)
goto done; goto done;
/* Cases in which we need to copyout */ /* Cases in which we need to copyout */
switch (uap->cmd) { switch (uap->cmd) {
case IPC_STAT: case IPC_STAT:
@ -894,7 +893,7 @@ shminit(void)
static int static int
shmunload(void) shmunload(void)
{ {
int i; int i;
if (shm_nused > 0) if (shm_nused > 0)
return (EBUSY); return (EBUSY);
@ -995,8 +994,7 @@ oshmctl(struct thread *td, struct oshmctl_args *uap)
outbuf.shm_ctime = shmseg->u.shm_ctime; outbuf.shm_ctime = shmseg->u.shm_ctime;
outbuf.shm_handle = shmseg->object; outbuf.shm_handle = shmseg->object;
SYSVSHM_UNLOCK(); SYSVSHM_UNLOCK();
error = copyout(&outbuf, uap->ubuf, sizeof(outbuf)); return (copyout(&outbuf, uap->ubuf, sizeof(outbuf)));
return (error);
#else #else
return (EINVAL); return (EINVAL);
#endif #endif
@ -1021,14 +1019,12 @@ struct shmsys_args {
int int
sys_shmsys(struct thread *td, struct shmsys_args *uap) sys_shmsys(struct thread *td, struct shmsys_args *uap)
{ {
int error;
if (!prison_allow(td->td_ucred, PR_ALLOW_SYSVIPC)) if (!prison_allow(td->td_ucred, PR_ALLOW_SYSVIPC))
return (ENOSYS); return (ENOSYS);
if (uap->which < 0 || uap->which >= nitems(shmcalls)) if (uap->which < 0 || uap->which >= nitems(shmcalls))
return (EINVAL); return (EINVAL);
error = (*shmcalls[uap->which])(td, &uap->a2); return ((*shmcalls[uap->which])(td, &uap->a2));
return (error);
} }
#endif /* i386 && (COMPAT_FREEBSD4 || COMPAT_43) */ #endif /* i386 && (COMPAT_FREEBSD4 || COMPAT_43) */
@ -1087,7 +1083,7 @@ int
freebsd7_freebsd32_shmctl(struct thread *td, freebsd7_freebsd32_shmctl(struct thread *td,
struct freebsd7_freebsd32_shmctl_args *uap) struct freebsd7_freebsd32_shmctl_args *uap)
{ {
int error = 0; int error;
union { union {
struct shmid_ds shmid_ds; struct shmid_ds shmid_ds;
struct shm_info shm_info; struct shm_info shm_info;
@ -1114,11 +1110,11 @@ freebsd7_freebsd32_shmctl(struct thread *td,
CP(u32.shmid_ds32, u.shmid_ds, shm_dtime); CP(u32.shmid_ds32, u.shmid_ds, shm_dtime);
CP(u32.shmid_ds32, u.shmid_ds, shm_ctime); CP(u32.shmid_ds32, u.shmid_ds, shm_ctime);
} }
error = kern_shmctl(td, uap->shmid, uap->cmd, (void *)&u, &sz); error = kern_shmctl(td, uap->shmid, uap->cmd, (void *)&u, &sz);
if (error) if (error)
goto done; goto done;
/* Cases in which we need to copyout */ /* Cases in which we need to copyout */
switch (uap->cmd) { switch (uap->cmd) {
case IPC_INFO: case IPC_INFO:
@ -1172,7 +1168,7 @@ done:
int int
freebsd32_shmctl(struct thread *td, struct freebsd32_shmctl_args *uap) freebsd32_shmctl(struct thread *td, struct freebsd32_shmctl_args *uap)
{ {
int error = 0; int error;
union { union {
struct shmid_ds shmid_ds; struct shmid_ds shmid_ds;
struct shm_info shm_info; struct shm_info shm_info;
@ -1184,7 +1180,7 @@ freebsd32_shmctl(struct thread *td, struct freebsd32_shmctl_args *uap)
struct shminfo32 shminfo32; struct shminfo32 shminfo32;
} u32; } u32;
size_t sz; size_t sz;
if (uap->cmd == IPC_SET) { if (uap->cmd == IPC_SET) {
if ((error = copyin(uap->buf, &u32.shmid_ds32, if ((error = copyin(uap->buf, &u32.shmid_ds32,
sizeof(u32.shmid_ds32)))) sizeof(u32.shmid_ds32))))
@ -1199,11 +1195,11 @@ freebsd32_shmctl(struct thread *td, struct freebsd32_shmctl_args *uap)
CP(u32.shmid_ds32, u.shmid_ds, shm_dtime); CP(u32.shmid_ds32, u.shmid_ds, shm_dtime);
CP(u32.shmid_ds32, u.shmid_ds, shm_ctime); CP(u32.shmid_ds32, u.shmid_ds, shm_ctime);
} }
error = kern_shmctl(td, uap->shmid, uap->cmd, (void *)&u, &sz); error = kern_shmctl(td, uap->shmid, uap->cmd, (void *)&u, &sz);
if (error) if (error)
goto done; goto done;
/* Cases in which we need to copyout */ /* Cases in which we need to copyout */
switch (uap->cmd) { switch (uap->cmd) {
case IPC_INFO: case IPC_INFO:
@ -1270,11 +1266,11 @@ struct freebsd7_shmctl_args {
int int
freebsd7_shmctl(struct thread *td, struct freebsd7_shmctl_args *uap) freebsd7_shmctl(struct thread *td, struct freebsd7_shmctl_args *uap)
{ {
int error = 0; int error;
struct shmid_ds_old old; struct shmid_ds_old old;
struct shmid_ds buf; struct shmid_ds buf;
size_t bufsz; size_t bufsz;
/* /*
* The only reason IPC_INFO, SHM_INFO, SHM_STAT exists is to support * The only reason IPC_INFO, SHM_INFO, SHM_STAT exists is to support
* Linux binaries. If we see the call come through the FreeBSD ABI, * Linux binaries. If we see the call come through the FreeBSD ABI,
@ -1297,7 +1293,7 @@ freebsd7_shmctl(struct thread *td, struct freebsd7_shmctl_args *uap)
CP(old, buf, shm_dtime); CP(old, buf, shm_dtime);
CP(old, buf, shm_ctime); CP(old, buf, shm_ctime);
} }
error = kern_shmctl(td, uap->shmid, uap->cmd, (void *)&buf, &bufsz); error = kern_shmctl(td, uap->shmid, uap->cmd, (void *)&buf, &bufsz);
if (error) if (error)
goto done; goto done;