s3-notify: Simplify if-expressions
authorVolker Lendecke <vl@samba.org>
Thu, 15 Mar 2012 11:22:50 +0000 (12:22 +0100)
committerVolker Lendecke <vl@samba.org>
Fri, 16 Mar 2012 10:20:11 +0000 (11:20 +0100)
source3/smbd/notify_internal.c

index d442367b2b06d449d8fc9ba7cfe01a63a72c8313..599c9941693e81e4ab82ea491f24e2c75b6dc0da 100644 (file)
@@ -958,6 +958,7 @@ void notify_trigger(struct notify_context *notify,
                int p_len = p - path;
                int min_i, max_i, i;
                struct notify_depth *d = &notify->array->depth[depth];
+               uint32_t d_max_mask;
                next_p = strchr(p+1, '/');
 
                /* see if there are any entries at this depth */
@@ -966,14 +967,11 @@ void notify_trigger(struct notify_context *notify,
                /* try to skip based on the maximum mask. If next_p is
                 NULL then we know it will be a 'this directory'
                 match, otherwise it must be a subdir match */
-               if (next_p != NULL) {
-                       if (0 == (filter & d->max_mask_subdir)) {
-                               continue;
-                       }
-               } else {
-                       if (0 == (filter & d->max_mask)) {
-                               continue;
-                       }
+
+               d_max_mask = next_p ? d->max_mask_subdir : d->max_mask;
+
+               if ((filter & d_max_mask) == 0) {
+                       continue;
                }
 
                /* we know there is an entry here worth looking
@@ -1009,17 +1007,16 @@ void notify_trigger(struct notify_context *notify,
                /* we now know that the entries start at min_i */
                for (i=min_i;i<d->num_entries;i++) {
                        struct notify_entry *e = &d->entries[i];
+                       uint32_t e_filter;
                        if (p_len != e->path_len ||
                            strncmp(path, e->path, p_len) != 0) break;
-                       if (next_p != NULL) {
-                               if (0 == (filter & e->subdir_filter)) {
-                                       continue;
-                               }
-                       } else {
-                               if (0 == (filter & e->filter)) {
-                                       continue;
-                               }
+
+                       e_filter = next_p ? e->subdir_filter : e->filter;
+
+                       if ((filter & e_filter) == 0) {
+                               continue;
                        }
+
                        status = notify_send(notify, e, path + e->path_len + 1,
                                             action);