Spelling fixes for lib/compression.
[sfrench/samba-autobuild/.git] / source3 / smbd / notify_internal.c
index a42404db3e6b4acbe99bca99ac6e61f90d6ed5a6..0467e672c1610e5cd749aed3f72100fc0c364722 100644 (file)
@@ -101,7 +101,7 @@ struct notify_context *notify_init(TALLOC_CTX *mem_ctx, struct server_id server,
        }
 
        notify->db_onelevel = db_open(notify, lock_path("notify_onelevel.tdb"),
-                                     0, TDB_SEQNUM|TDB_CLEAR_IF_FIRST,
+                                     0, TDB_CLEAR_IF_FIRST,
                                      O_RDWR|O_CREAT, 0644);
        if (notify->db_onelevel == NULL) {
                talloc_free(notify);
@@ -200,10 +200,8 @@ static NTSTATUS notify_load(struct notify_context *notify, struct db_record *rec
 /*
   compare notify entries for sorting
 */
-static int notify_compare(const void *p1, const void *p2)
+static int notify_compare(const struct notify_entry *e1, const struct notify_entry *e2)
 {
-       const struct notify_entry *e1 = (const struct notify_entry *)p1;
-       const struct notify_entry *e2 = (const struct notify_entry *)p2;
        return strcmp(e1->path, e2->path);
 }
 
@@ -339,9 +337,7 @@ static NTSTATUS notify_add_array(struct notify_context *notify, struct db_record
        d->max_mask |= e->filter;
        d->max_mask_subdir |= e->subdir_filter;
 
-       if (d->num_entries > 1) {
-               qsort(d->entries, d->num_entries, sizeof(d->entries[0]), notify_compare);
-       }
+       TYPESAFE_QSORT(d->entries, d->num_entries, notify_compare);
 
        /* recalculate the maximum masks */
        d->max_mask = 0;
@@ -545,13 +541,17 @@ NTSTATUS notify_remove_onelevel(struct notify_context *notify,
        NTSTATUS status;
        int i;
 
+       if (notify == NULL) {
+               return NT_STATUS_NOT_IMPLEMENTED;
+       }
+
        array = talloc_zero(talloc_tos(), struct notify_entry_array);
        if (array == NULL) {
                return NT_STATUS_NO_MEMORY;
        }
 
        rec = notify->db_onelevel->fetch_locked(
-               notify->db_onelevel, talloc_tos(),
+               notify->db_onelevel, array,
                make_tdb_data((uint8_t *)fid, sizeof(*fid)));
        if (rec == NULL) {
                DEBUG(10, ("notify_remove_onelevel: fetch_locked for %s failed"
@@ -786,6 +786,10 @@ void notify_onelevel(struct notify_context *notify, uint32_t action,
        bool have_dead_entries = false;
        int i;
 
+       if (notify == NULL) {
+               return;
+       }
+
        array = talloc_zero(talloc_tos(), struct notify_entry_array);
        if (array == NULL) {
                return;