notify_inotify: Simplify inotify_dispatch
authorVolker Lendecke <vl@samba.org>
Thu, 4 Dec 2014 16:01:17 +0000 (16:01 +0000)
committerJeremy Allison <jra@samba.org>
Tue, 9 Dec 2014 05:37:24 +0000 (06:37 +0100)
Normally, I'm trying to simplify things with early returns. But in
this case I think the reverse makes the if-condition easier to
understand

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Dec  9 06:37:24 CET 2014 on sn-devel-104

source3/smbd/notify_inotify.c

index 944f27a1553e60fcb145ae06b86c99c562842453..8f4712404f4a51513affd7ae165365ce783576d7 100644 (file)
@@ -168,23 +168,25 @@ static void inotify_dispatch(struct inotify_private *in,
                }
        }
 
-       /* SMB expects a file rename to generate three events, two for
-          the rename and the other for a modify of the
-          destination. Strange! */
-       if (ne.action != NOTIFY_ACTION_NEW_NAME ||
-           (e->mask & IN_ISDIR) != 0) {
-               return;
-       }
+       if ((ne.action == NOTIFY_ACTION_NEW_NAME) &&
+           ((e->mask & IN_ISDIR) == 0)) {
 
-       ne.action = NOTIFY_ACTION_MODIFIED;
-       e->mask = IN_ATTRIB;
+               /*
+                * SMB expects a file rename to generate three events, two for
+                * the rename and the other for a modify of the
+                * destination. Strange!
+                */
 
-       for (w=in->watches;w;w=next) {
-               next = w->next;
-               if (w->wd == e->wd && filter_match(w, e) &&
-                   !(w->filter & FILE_NOTIFY_CHANGE_CREATION)) {
-                       ne.dir = w->path;
-                       w->callback(in->ctx, w->private_data, &ne);
+               ne.action = NOTIFY_ACTION_MODIFIED;
+               e->mask = IN_ATTRIB;
+
+               for (w=in->watches;w;w=next) {
+                       next = w->next;
+                       if (w->wd == e->wd && filter_match(w, e) &&
+                           !(w->filter & FILE_NOTIFY_CHANGE_CREATION)) {
+                               ne.dir = w->path;
+                               w->callback(in->ctx, w->private_data, &ne);
+                       }
                }
        }
 }