From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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) 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 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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 -- 2.9.3