diff options
author | Christoph Hellwig <hch@lst.de> | 2018-03-05 10:15:25 -0500 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2018-05-26 03:16:44 -0400 |
commit | a0f8dcfc607d8d113090ff36eee2ee406463bb0e (patch) | |
tree | b42dc59a8984807a86041faeb088523439541b99 /fs/select.c | |
parent | 8f546ae1fc5ce8396827d4868c7eee1f1cc6947a (diff) |
fs: cleanup do_pollfd
Use straightline code with failure handling gotos instead of a lot
of nested conditionals.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Diffstat (limited to 'fs/select.c')
-rw-r--r-- | fs/select.c | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/fs/select.c b/fs/select.c index a87f396f0313..25da26253485 100644 --- a/fs/select.c +++ b/fs/select.c | |||
@@ -812,34 +812,32 @@ static inline __poll_t do_pollfd(struct pollfd *pollfd, poll_table *pwait, | |||
812 | bool *can_busy_poll, | 812 | bool *can_busy_poll, |
813 | __poll_t busy_flag) | 813 | __poll_t busy_flag) |
814 | { | 814 | { |
815 | __poll_t mask; | 815 | int fd = pollfd->fd; |
816 | int fd; | 816 | __poll_t mask = 0, filter; |
817 | 817 | struct fd f; | |
818 | mask = 0; | 818 | |
819 | fd = pollfd->fd; | 819 | if (fd < 0) |
820 | if (fd >= 0) { | 820 | goto out; |
821 | struct fd f = fdget(fd); | 821 | mask = EPOLLNVAL; |
822 | mask = EPOLLNVAL; | 822 | f = fdget(fd); |
823 | if (f.file) { | 823 | if (!f.file) |
824 | /* userland u16 ->events contains POLL... bitmap */ | 824 | goto out; |
825 | __poll_t filter = demangle_poll(pollfd->events) | | 825 | |
826 | EPOLLERR | EPOLLHUP; | 826 | /* userland u16 ->events contains POLL... bitmap */ |
827 | mask = DEFAULT_POLLMASK; | 827 | filter = demangle_poll(pollfd->events) | EPOLLERR | EPOLLHUP; |
828 | if (f.file->f_op->poll) { | 828 | mask = DEFAULT_POLLMASK; |
829 | pwait->_key = filter; | 829 | if (f.file->f_op->poll) { |
830 | pwait->_key |= busy_flag; | 830 | pwait->_key = filter | busy_flag; |
831 | mask = f.file->f_op->poll(f.file, pwait); | 831 | mask = f.file->f_op->poll(f.file, pwait); |
832 | if (mask & busy_flag) | 832 | if (mask & busy_flag) |
833 | *can_busy_poll = true; | 833 | *can_busy_poll = true; |
834 | } | ||
835 | /* Mask out unneeded events. */ | ||
836 | mask &= filter; | ||
837 | fdput(f); | ||
838 | } | ||
839 | } | 834 | } |
835 | mask &= filter; /* Mask out unneeded events. */ | ||
836 | fdput(f); | ||
837 | |||
838 | out: | ||
840 | /* ... and so does ->revents */ | 839 | /* ... and so does ->revents */ |
841 | pollfd->revents = mangle_poll(mask); | 840 | pollfd->revents = mangle_poll(mask); |
842 | |||
843 | return mask; | 841 | return mask; |
844 | } | 842 | } |
845 | 843 | ||