summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2004-11-15 21:51:28 +0000
committerphk <phk@FreeBSD.org>2004-11-15 21:51:28 +0000
commit8f49227258f1574dc23538fe58e943b80a7027fe (patch)
treefa27fed13d1b84903393d37cfbf51b17bf0ec736 /sys
parent784764896a15a7f68ede957b77a19af965cd5089 (diff)
downloadFreeBSD-src-8f49227258f1574dc23538fe58e943b80a7027fe.zip
FreeBSD-src-8f49227258f1574dc23538fe58e943b80a7027fe.tar.gz
Straighten the ioctl function out to have only one exit point.
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/sys_pipe.c30
1 files changed, 13 insertions, 17 deletions
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
OpenPOWER on IntegriCloud