aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJonathan Corbet <corbet@lwn.net>2009-02-01 16:52:56 -0500
committerJonathan Corbet <corbet@lwn.net>2009-03-16 10:34:35 -0400
commit60aa49243d09afc873f082567d2e3c16634ced84 (patch)
treebb7c8d9668b35a3aa4e90d0a62500ac9d3e67f7f /fs
parent76398425bb06b07cc3a3b1ce169c67dc9d6874ed (diff)
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 <viro@ZenIV.linux.org.uk> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Diffstat (limited to 'fs')
-rw-r--r--fs/fcntl.c2
-rw-r--r--fs/ioctl.c2
-rw-r--r--fs/pipe.c16
3 files changed, 6 insertions, 14 deletions
diff --git a/fs/fcntl.c b/fs/fcntl.c
index 431bb6459273..d865ca66ccba 100644
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@ -184,6 +184,8 @@ static int setfl(int fd, struct file * filp, unsigned long arg)
184 error = filp->f_op->fasync(fd, filp, (arg & FASYNC) != 0); 184 error = filp->f_op->fasync(fd, filp, (arg & FASYNC) != 0);
185 if (error < 0) 185 if (error < 0)
186 goto out; 186 goto out;
187 if (error > 0)
188 error = 0;
187 } 189 }
188 spin_lock(&filp->f_lock); 190 spin_lock(&filp->f_lock);
189 filp->f_flags = (arg & SETFL_MASK) | (filp->f_flags & ~SETFL_MASK); 191 filp->f_flags = (arg & SETFL_MASK) | (filp->f_flags & ~SETFL_MASK);
diff --git a/fs/ioctl.c b/fs/ioctl.c
index e8e89edba576..ac2d47e43926 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -432,7 +432,7 @@ static int ioctl_fioasync(unsigned int fd, struct file *filp,
432 else 432 else
433 error = -ENOTTY; 433 error = -ENOTTY;
434 } 434 }
435 return error; 435 return error < 0 ? error : 0;
436} 436}
437 437
438static int ioctl_fsfreeze(struct file *filp) 438static int ioctl_fsfreeze(struct file *filp)
diff --git a/fs/pipe.c b/fs/pipe.c
index 14f502b89cf5..94ad15967cf9 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -667,10 +667,7 @@ pipe_read_fasync(int fd, struct file *filp, int on)
667 retval = fasync_helper(fd, filp, on, &inode->i_pipe->fasync_readers); 667 retval = fasync_helper(fd, filp, on, &inode->i_pipe->fasync_readers);
668 mutex_unlock(&inode->i_mutex); 668 mutex_unlock(&inode->i_mutex);
669 669
670 if (retval < 0) 670 return retval;
671 return retval;
672
673 return 0;
674} 671}
675 672
676 673
@@ -684,10 +681,7 @@ pipe_write_fasync(int fd, struct file *filp, int on)
684 retval = fasync_helper(fd, filp, on, &inode->i_pipe->fasync_writers); 681 retval = fasync_helper(fd, filp, on, &inode->i_pipe->fasync_writers);
685 mutex_unlock(&inode->i_mutex); 682 mutex_unlock(&inode->i_mutex);
686 683
687 if (retval < 0) 684 return retval;
688 return retval;
689
690 return 0;
691} 685}
692 686
693 687
@@ -706,11 +700,7 @@ pipe_rdwr_fasync(int fd, struct file *filp, int on)
706 fasync_helper(-1, filp, 0, &pipe->fasync_readers); 700 fasync_helper(-1, filp, 0, &pipe->fasync_readers);
707 } 701 }
708 mutex_unlock(&inode->i_mutex); 702 mutex_unlock(&inode->i_mutex);
709 703 return retval;
710 if (retval < 0)
711 return retval;
712
713 return 0;
714} 704}
715 705
716 706