From 8f49227258f1574dc23538fe58e943b80a7027fe Mon Sep 17 00:00:00 2001 From: phk Date: Mon, 15 Nov 2004 21:51:28 +0000 Subject: Straighten the ioctl function out to have only one exit point. --- sys/kern/sys_pipe.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'sys') diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c index 6865546..d53c8a3 100644 --- a/sys/kern/sys_pipe.c +++ b/sys/kern/sys_pipe.c @@ -1258,9 +1258,7 @@ pipe_ioctl(fp, cmd, data, active_cred, td) struct thread *td; { struct pipe *mpipe = fp->f_data; -#ifdef MAC int error; -#endif PIPE_LOCK(mpipe); @@ -1272,11 +1270,11 @@ pipe_ioctl(fp, cmd, data, active_cred, td) } #endif + error = 0; switch (cmd) { case FIONBIO: - PIPE_UNLOCK(mpipe); - return (0); + break; case FIOASYNC: if (*(int *)data) { @@ -1284,40 +1282,38 @@ pipe_ioctl(fp, cmd, data, active_cred, td) } else { mpipe->pipe_state &= ~PIPE_ASYNC; } - PIPE_UNLOCK(mpipe); - return (0); + break; case FIONREAD: if (mpipe->pipe_state & PIPE_DIRECTW) *(int *)data = mpipe->pipe_map.cnt; else *(int *)data = mpipe->pipe_buffer.cnt; - PIPE_UNLOCK(mpipe); - return (0); + break; case FIOSETOWN: - PIPE_UNLOCK(mpipe); - return (fsetown(*(int *)data, &mpipe->pipe_sigio)); + error = fsetown(*(int *)data, &mpipe->pipe_sigio); + break; case FIOGETOWN: - PIPE_UNLOCK(mpipe); *(int *)data = fgetown(&mpipe->pipe_sigio); - return (0); + break; /* This is deprecated, FIOSETOWN should be used instead. */ case TIOCSPGRP: - PIPE_UNLOCK(mpipe); - return (fsetown(-(*(int *)data), &mpipe->pipe_sigio)); + error = fsetown(-(*(int *)data), &mpipe->pipe_sigio); + break; /* This is deprecated, FIOGETOWN should be used instead. */ case TIOCGPGRP: - PIPE_UNLOCK(mpipe); *(int *)data = -fgetown(&mpipe->pipe_sigio); - return (0); + break; + default: + error = ENOTTY; } PIPE_UNLOCK(mpipe); - return (ENOTTY); + return (error); } static int -- cgit v1.1