Received: by 10.223.176.46 with SMTP id f43csp3342668wra; Mon, 22 Jan 2018 12:27:56 -0800 (PST) X-Google-Smtp-Source: AH8x224Je2FBEEE+loPY1f1mU2dTj4ANowpsrfdBfVibjr8xGe46+ut7zFeOAqLEIejl0WkLu+eg X-Received: by 10.36.4.212 with SMTP id 203mr74514itb.132.1516652875977; Mon, 22 Jan 2018 12:27:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516652875; cv=none; d=google.com; s=arc-20160816; b=eiSGiKvZEAq/ifu5Ft1hzie8/Tcg680s/laiOLj68BFlHyJr7cq1pr3EhDrG0+GXYV nv+W9eHxjq1htPJcIkyDj2qymWMf5loEOoX7+orJzHvrkFsSj+swmraRkf1qZUfmn+yh Fd0A7rtuDBcu2VJKh/yhqGd4WH2hQrI0H0oLwVDfPN/PyAqfhrbKQjrHiduyjffbyUHj lUHQWaco5yIUxSq7/3VQ9TaKKZALdIzYWXsrucq6MU2tp4jd4xIgWIrs05TVlp6AqPef nxMC2ygPJgHfz9R3PaiXBl/PUIx2wmrkW9+lOWOXiwHU2evEKq/FCRa/nOoCUNjURDcX UglQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=y24Lcs57H4zvVRQERew6kdoS0xRLnU5XfbvZ53x9bjg=; b=nKhsHT/sFfY9tbX/cIUl2709jaypRZR7W/smEz5nHW1l9wwfDI5kSWn5C2kppAKAxz Cto4WuCSzTdQ23ZudigFf3pkPUSTivZQ3F0meTxoFWOINbkJhRbfr63I42jpGfgH2x4a HQL5O0t53ljdfw0w9qRYg7NhAMpFDutEXOhgrJtq17AyEAigW/Ed+zpWq7NyuV5pYCJI obfXGZAdrLUdi0t23UbYJqMC+uQ3jLKOQVhlL1DvzrygHQ/2Fe+VDL62YmLN5usKrySK WfosnAzVD+HtIUNgQZA9BJnwHOnQ4Ke1KI9IUVy3svG1nHBIiwrrdEwGgoxT27P+j94L xlXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=DFQfyHAd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e5si6278175itf.84.2018.01.22.12.27.43; Mon, 22 Jan 2018 12:27:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=DFQfyHAd; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751509AbeAVUZN (ORCPT + 99 others); Mon, 22 Jan 2018 15:25:13 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:60235 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751126AbeAVUNV (ORCPT ); Mon, 22 Jan 2018 15:13:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=y24Lcs57H4zvVRQERew6kdoS0xRLnU5XfbvZ53x9bjg=; b=DFQfyHAdD5Md21gTkogKLXqP6 3kHj+dSclHt44Z+Drmh9eS1iSzG/pqvRiPMWMcx5uVwEu8ZuqZ8z4qyhVplxr9PBzlp/mRKGLEdkx n7hFTmuw6b1uubxX08/p1VTNbHslIlgB8/KBnGI0W84DSNOPgH+TIAuAkvgGFDFBRMWOLdYBisJDK ALOuQ2d4Do5NMZgkxjDKIn7Q+KiUoIAZg+td/TJvBjz7iAhTy+o9a0yE9fUMBuiIv/1fYfRxfd/I4 FIFrx/45re4mw72L5bbjx57svs64qqsqrade4dilc7IJjGRFtrLVeU4txnuBUKySc2fvM4yRlHfN9 iY54uREDw==; Received: from 178.114.226.247.wireless.dyn.drei.com ([178.114.226.247] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.89 #1 (Red Hat Linux)) id 1ediT1-0007a4-3X; Mon, 22 Jan 2018 20:13:19 +0000 From: Christoph Hellwig To: viro@zeniv.linux.org.uk Cc: Avi Kivity , linux-aio@kvack.org, linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 10/36] fs: cleanup do_pollfd Date: Mon, 22 Jan 2018 21:12:17 +0100 Message-Id: <20180122201243.31610-11-hch@lst.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180122201243.31610-1-hch@lst.de> References: <20180122201243.31610-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use straigline code with failure handling gotos instead of a lot of nested conditionals. Signed-off-by: Christoph Hellwig --- fs/select.c | 48 +++++++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/fs/select.c b/fs/select.c index 4e1dccac2702..2ad66647f340 100644 --- a/fs/select.c +++ b/fs/select.c @@ -806,34 +806,32 @@ static inline __poll_t do_pollfd(struct pollfd *pollfd, poll_table *pwait, bool *can_busy_poll, __poll_t busy_flag) { - __poll_t mask; - int fd; - - mask = 0; - fd = pollfd->fd; - if (fd >= 0) { - struct fd f = fdget(fd); - mask = POLLNVAL; - if (f.file) { - /* userland u16 ->events contains POLL... bitmap */ - __poll_t filter = demangle_poll(pollfd->events) | - POLLERR | POLLHUP; - mask = DEFAULT_POLLMASK; - if (f.file->f_op->poll) { - pwait->_key = filter; - pwait->_key |= busy_flag; - mask = f.file->f_op->poll(f.file, pwait); - if (mask & busy_flag) - *can_busy_poll = true; - } - /* Mask out unneeded events. */ - mask &= filter; - fdput(f); - } + __poll_t mask = 0, filter; + struct fd f; + + if (pollfd->fd < 0) + goto out; + mask = POLLNVAL; + f = fdget(pollfd->fd); + if (!f.file) + goto out; + + /* userland u16 ->events contains POLL... bitmap */ + filter = demangle_poll(pollfd->events) | POLLERR | POLLHUP; + mask = DEFAULT_POLLMASK; + if (f.file->f_op->poll) { + pwait->_key = filter | busy_flag; + mask = f.file->f_op->poll(f.file, pwait); + if (mask & busy_flag) + *can_busy_poll = true; } + + /* Mask out unneeded events. */ + mask &= filter; + fdput(f); +out: /* ... and so does ->revents */ pollfd->revents = mangle_poll(mask); - return mask; } -- 2.14.2