From patchwork Thu Feb 9 12:45:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinglong Mee X-Patchwork-Id: 9564521 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 7D07A601C3 for ; Thu, 9 Feb 2017 13:12:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 65B26284E7 for ; Thu, 9 Feb 2017 13:12:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A5112850D; Thu, 9 Feb 2017 13:12:51 +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.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 16554284E7 for ; Thu, 9 Feb 2017 13:12:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751665AbdBINML (ORCPT ); Thu, 9 Feb 2017 08:12:11 -0500 Received: from mail-it0-f67.google.com ([209.85.214.67]:35447 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751820AbdBINMJ (ORCPT ); Thu, 9 Feb 2017 08:12:09 -0500 Received: by mail-it0-f67.google.com with SMTP id 203so2173989ith.2 for ; Thu, 09 Feb 2017 05:12:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:references:cc:to:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=d4WMDRXQmASz9r382BBMsEcVlNWKBG3dR+hGWOQURRg=; b=TZrlL4VdY12HJQGfV5WIlSegAQMzmNhesRUupvIFtLXrNnravfmRNb4lzTUfS6M1UN eLF6GuPS2Q9V4bTVaqHIaOPXwomhwLbnX/uXCjyuHxnehQ/NGQVXrv1/H/JY9bn6MWn2 XALs7gh3+xLERWKTyr2I0Ie2Goqp/bkl6Fdop1IXcf7xmSppaynktMypSlw4XWBMq/Fv H0ZDOAGxpd+3f9yDg10YLt4hffj946U9Nce1KUorPprggNDF1QzrSNjKzXAt3nUBnsmK fAQO9Ko4Z1Y81O1IMa2XgPzX0b0WJy66B4oIyGUyUmX24EVpGW4GHEn4dZ6+BszIaBBc g73Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:references:cc:to:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=d4WMDRXQmASz9r382BBMsEcVlNWKBG3dR+hGWOQURRg=; b=YMFpE07wMm6xhuxAOBL0BzMTWs1CTtKWjuU865Q9mulAa2rnOYDu/MOwD3Yj2Yd0YM BntrOU5nQOhS7ut+4qQqw3R5qxoInRcdY5J+3RYk7E0YIPQPR5xmR1onGiyBEiBFWNUY xX5Mlk2yOuKhimDo+upNHwKx6BecF0iyuaNu/4D2F7EoajT04wceHpFL1juszyvOoUe6 Z3Mg8kdwRkrdYnzu4M/FLYoNS9KhLh5tUA/DuSlKJaD+qtFX/9zviurAQT1gAYM1ZtcK Ui/r3ijqkoPuQ9M1iK/9rZs7IS5GpzMF8F1MRmG1uAa76Zo05fMGLbiNV3AyC7CvlT+1 x+9Q== X-Gm-Message-State: AMke39nFu+EJlQxpy0Pg9xff/p4sgoQA7WT4BBnkG5Kz5W+fR6MgHN97BZSbpqN/98iQ7A== X-Received: by 10.36.53.210 with SMTP id k201mr2875323ita.21.1486644329099; Thu, 09 Feb 2017 04:45:29 -0800 (PST) Received: from [192.168.0.107] ([182.139.116.95]) by smtp.gmail.com with ESMTPSA id r203sm2833121itc.5.2017.02.09.04.45.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Feb 2017 04:45:28 -0800 (PST) Subject: [PATCH] fanotify: simplify the code of fanotify_merge References: <61c55ce2-7c17-2744-502e-f33067ded99a@gmail.com> Cc: Amir Goldstein , linux-fsdevel , Al Viro , Jan Kara , Kinglong Mee To: Eric Paris From: Kinglong Mee Message-ID: Date: Thu, 9 Feb 2017 20:45:22 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: 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 v2, change the subject to "simplify the code" Signed-off-by: Kinglong Mee --- fs/notify/fanotify/fanotify.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/fs/notify/fanotify/fanotify.c b/fs/notify/fanotify/fanotify.c index bbc175d..a4c4622 100644 --- a/fs/notify/fanotify/fanotify.c +++ b/fs/notify/fanotify/fanotify.c @@ -31,7 +31,6 @@ static bool should_merge(struct fsnotify_event *old_fsn, static int fanotify_merge(struct list_head *list, struct fsnotify_event *event) { struct fsnotify_event *test_event; - bool do_merge = false; pr_debug("%s: list=%p event=%p\n", __func__, list, event); @@ -47,16 +46,12 @@ static int fanotify_merge(struct list_head *list, struct fsnotify_event *event) list_for_each_entry_reverse(test_event, list, list) { if (should_merge(test_event, event)) { - do_merge = true; - break; + test_event->mask |= event->mask; + return 1; } } - if (!do_merge) - return 0; - - test_event->mask |= event->mask; - return 1; + return 0; } #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS