diff mbox

fs: select: Refine the end_time checks in do_select

Message ID 1495596673-28300-1-git-send-email-gfree.wind@vip.163.com (mailing list archive)
State New, archived
Headers show

Commit Message

gfree.wind@vip.163.com May 24, 2017, 3:31 a.m. UTC
From: Gao Feng <gfree.wind@vip.163.com>

Refine the end_time condition check statements to decrease the unncessary
checks and enhance the readability.

Signed-off-by: Gao Feng <gfree.wind@vip.163.com>
---
 fs/select.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
diff mbox

Patch

diff --git a/fs/select.c b/fs/select.c
index d6c652a..34257dd 100644
--- a/fs/select.c
+++ b/fs/select.c
@@ -468,13 +468,15 @@  static int do_select(int n, fd_set_bits *fds, struct timespec64 *end_time)
 
 	poll_initwait(&table);
 	wait = &table.pt;
-	if (end_time && !end_time->tv_sec && !end_time->tv_nsec) {
-		wait->_qproc = NULL;
-		timed_out = 1;
-	}
 
-	if (end_time && !timed_out)
-		slack = select_estimate_accuracy(end_time);
+	if (end_time) {
+		if (end_time->tv_sec || end_time->tv_nsec) {
+			slack = select_estimate_accuracy(end_time);
+		} else {
+			wait->_qproc = NULL;
+			timed_out = 1;
+		}
+	}
 
 	retval = 0;
 	for (;;) {