diff mbox

fanotify: simplify the logical of fanotify_merge

Message ID 61c55ce2-7c17-2744-502e-f33067ded99a@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Kinglong Mee Feb. 8, 2017, 12:54 p.m. UTC
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
---
 fs/notify/fanotify/fanotify.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

Comments

Amir Goldstein Feb. 8, 2017, 1:53 p.m. UTC | #1
On Wed, Feb 8, 2017 at 2:54 PM, Kinglong Mee <kinglongmee@gmail.com> wrote:

Although there is not much to write, I don't think that subject-only
patches are encouraged.

For the subject there is a typo s/logical/logic, although I wouldn't
go as far as
calling this 'logic', might have used 'simplify the code' instead.

> Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
> ---
>  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
>
diff mbox

Patch

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