From 60aa49243d09afc873f082567d2e3c16634ced84 Mon Sep 17 00:00:00 2001 From: Jonathan Corbet Date: Sun, 1 Feb 2009 14:52:56 -0700 Subject: Rationalize fasync return values Most fasync implementations do something like: return fasync_helper(...); But fasync_helper() will return a positive value at times - a feature used in at least one place. Thus, a number of other drivers do: err = fasync_helper(...); if (err < 0) return err; return 0; In the interests of consistency and more concise code, it makes sense to map positive return values onto zero where ->fasync() is called. Cc: Al Viro Signed-off-by: Jonathan Corbet --- fs/fcntl.c | 2 ++ fs/ioctl.c | 2 +- fs/pipe.c | 16 +++------------- 3 files changed, 6 insertions(+), 14 deletions(-) (limited to 'fs') diff --git a/fs/fcntl.c b/fs/fcntl.c index 431bb64..d865ca66 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c @@ -184,6 +184,8 @@ static int setfl(int fd, struct file * filp, unsigned long arg) error = filp->f_op->fasync(fd, filp, (arg & FASYNC) != 0); if (error < 0) goto out; + if (error > 0) + error = 0; } spin_lock(&filp->f_lock); filp->f_flags = (arg & SETFL_MASK) | (filp->f_flags & ~SETFL_MASK); diff --git a/fs/ioctl.c b/fs/ioctl.c index e8e89ed..ac2d47e 100644 --- a/fs/ioctl.c +++ b/fs/ioctl.c @@ -432,7 +432,7 @@ static int ioctl_fioasync(unsigned int fd, struct file *filp, else error = -ENOTTY; } - return error; + return error < 0 ? error : 0; } static int ioctl_fsfreeze(struct file *filp) diff --git a/fs/pipe.c b/fs/pipe.c index 14f502b..94ad159 100644 --- a/fs/pipe.c +++ b/fs/pipe.c @@ -667,10 +667,7 @@ pipe_read_fasync(int fd, struct file *filp, int on) retval = fasync_helper(fd, filp, on, &inode->i_pipe->fasync_readers); mutex_unlock(&inode->i_mutex); - if (retval < 0) - return retval; - - return 0; + return retval; } @@ -684,10 +681,7 @@ pipe_write_fasync(int fd, struct file *filp, int on) retval = fasync_helper(fd, filp, on, &inode->i_pipe->fasync_writers); mutex_unlock(&inode->i_mutex); - if (retval < 0) - return retval; - - return 0; + return retval; } @@ -706,11 +700,7 @@ pipe_rdwr_fasync(int fd, struct file *filp, int on) fasync_helper(-1, filp, 0, &pipe->fasync_readers); } mutex_unlock(&inode->i_mutex); - - if (retval < 0) - return retval; - - return 0; + return retval; } -- cgit v1.1