From patchwork Wed May 24 03:31:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: gfree.wind@vip.163.com X-Patchwork-Id: 9744923 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DF12D602A7 for ; Wed, 24 May 2017 03:37:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C05562885B for ; Wed, 24 May 2017 03:37:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B49DE28894; Wed, 24 May 2017 03:37:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1415E2885B for ; Wed, 24 May 2017 03:37:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761861AbdEXDhH (ORCPT ); Tue, 23 May 2017 23:37:07 -0400 Received: from mail-177180.vip.163.com ([123.58.177.180]:37430 "EHLO mail-177180.vip.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761739AbdEXDhH (ORCPT ); Tue, 23 May 2017 23:37:07 -0400 X-Greylist: delayed 346 seconds by postgrey-1.27 at vger.kernel.org; Tue, 23 May 2017 23:37:06 EDT Received: from ikuai8.com (unknown [114.242.17.234]) by smtp1 (Coremail) with SMTP id oGZ4CgBXJROD_iRZhiBEBQ--.22939S2; Wed, 24 May 2017 11:31:17 +0800 (CST) From: gfree.wind@vip.163.com To: viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org Cc: Gao Feng Subject: [PATCH] fs: select: Refine the end_time checks in do_select Date: Wed, 24 May 2017 11:31:13 +0800 Message-Id: <1495596673-28300-1-git-send-email-gfree.wind@vip.163.com> X-Mailer: git-send-email 1.9.1 X-CM-TRANSID: oGZ4CgBXJROD_iRZhiBEBQ--.22939S2 X-Coremail-Antispam: 1Uf129KBjvdXoWrtF1fuFWkKrW7Zw1fuF13CFg_yoWftrc_uF 92ya4vyFWjga15tFW0yws7JrWrCw4jgF4UGFWUKr9rJF4UJ3sYgF1kXFWUXFs7ua1jvryU CrW5ZasrKryftjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU8SeH3UUUUU== X-Originating-IP: [114.242.17.234] X-CM-SenderInfo: 5jiuvvgozl0vg6yl1hqrwthudrp/1tbiHQfgs1Qj2WELNQACs6 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Gao Feng Refine the end_time condition check statements to decrease the unncessary checks and enhance the readability. Signed-off-by: Gao Feng --- fs/select.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) 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 (;;) {