notify_inotify: Simplify filter_match
authorVolker Lendecke <vl@samba.org>
Sun, 26 Oct 2014 09:13:41 +0000 (09:13 +0000)
committerJeremy Allison <jra@samba.org>
Tue, 9 Dec 2014 03:12:08 +0000 (04:12 +0100)
Early returns make code simpler

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/notify_inotify.c

index 554277cabecbc5f01c2a383d4aed48c499415560..2425bb4a5bc1b261106cb7f49652b8a66c332b30 100644 (file)
@@ -75,6 +75,8 @@ static int inotify_destructor(struct inotify_private *in)
 static bool filter_match(struct inotify_watch_context *w,
                         struct inotify_event *e)
 {
+       bool ok;
+
        DEBUG(10, ("filter_match: e->mask=%x, w->mask=%x, w->filter=%x\n",
                   e->mask, w->mask, w->filter));
 
@@ -86,28 +88,25 @@ static bool filter_match(struct inotify_watch_context *w,
 
        /* SMB separates the filters for files and directories */
        if (e->mask & IN_ISDIR) {
-               if ((w->filter & FILE_NOTIFY_CHANGE_DIR_NAME) == 0) {
-                       return False;
-               }
-       } else {
-               if ((e->mask & IN_ATTRIB) &&
-                   (w->filter & (FILE_NOTIFY_CHANGE_ATTRIBUTES|
-                                 FILE_NOTIFY_CHANGE_LAST_WRITE|
-                                 FILE_NOTIFY_CHANGE_LAST_ACCESS|
-                                 FILE_NOTIFY_CHANGE_EA|
-                                 FILE_NOTIFY_CHANGE_SECURITY))) {
-                       return True;
-               }
-               if ((e->mask & IN_MODIFY) && 
-                   (w->filter & FILE_NOTIFY_CHANGE_ATTRIBUTES)) {
-                       return True;
-               }
-               if ((w->filter & FILE_NOTIFY_CHANGE_FILE_NAME) == 0) {
-                       return False;
-               }
+               ok = ((w->filter & FILE_NOTIFY_CHANGE_DIR_NAME) != 0);
+               return ok;
+       }
+
+       if ((e->mask & IN_ATTRIB) &&
+           (w->filter & (FILE_NOTIFY_CHANGE_ATTRIBUTES|
+                         FILE_NOTIFY_CHANGE_LAST_WRITE|
+                         FILE_NOTIFY_CHANGE_LAST_ACCESS|
+                         FILE_NOTIFY_CHANGE_EA|
+                         FILE_NOTIFY_CHANGE_SECURITY))) {
+               return True;
+       }
+       if ((e->mask & IN_MODIFY) &&
+           (w->filter & FILE_NOTIFY_CHANGE_ATTRIBUTES)) {
+               return True;
        }
 
-       return True;
+       ok = ((w->filter & FILE_NOTIFY_CHANGE_FILE_NAME) != 0);
+       return ok;
 }