smbd: Convert share_mode_data->num_share_modes into a boolean8
authorVolker Lendecke <vl@samba.org>
Wed, 11 Dec 2019 15:19:59 +0000 (16:19 +0100)
committerJeremy Allison <jra@samba.org>
Wed, 18 Dec 2019 00:05:13 +0000 (00:05 +0000)
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): Wed Dec 18 00:05:13 UTC 2019 on sn-devel-184

source3/librpc/idl/open_files.idl
source3/locking/share_mode_lock.c

index 261aed6d04e56e7d016d12165eef8def9fe5114c..432c1e71bc007463cdfe23716f21191539441571 100644 (file)
@@ -58,13 +58,13 @@ interface open_files
                [string,charset(UTF8)] char *servicepath;
                [string,charset(UTF8)] char *base_name;
                [string,charset(UTF8)] char *stream_name;
-               [skip] uint32 num_share_modes;
                uint32 num_delete_tokens;
                [size_is(num_delete_tokens)] delete_token delete_tokens[];
                NTTIME old_write_time;
                NTTIME changed_write_time;
                [skip] boolean8 fresh;
                [skip] boolean8 modified;
+               [skip] boolean8 have_share_modes;
                [ignore] file_id id; /* In memory key used to lookup cache. */
        } share_mode_data;
 
index 93800a6d524aad0e0297b55557c251929c72104c..ce22ce540cfa80690d40e9cd093582268cd6b9b5 100644 (file)
@@ -410,7 +410,7 @@ static struct share_mode_data *parse_share_modes(TALLOC_CTX *mem_ctx,
         * otherwise we'd have paniced before in
         * share_mode_data_store()
         */
-       d->num_share_modes = 1;
+       d->have_share_modes = true;
 
        return d;
 fail:
@@ -441,7 +441,7 @@ static NTSTATUS share_mode_data_store(
 
        d->sequence_number += 1;
 
-       if (d->num_share_modes == 0) {
+       if (!d->have_share_modes) {
                TDB_DATA key = dbwrap_record_get_key(rec);
                bool share_entries_exist;
                share_entries_exist = dbwrap_exists(share_entries_db, key);
@@ -692,7 +692,7 @@ static int share_mode_lock_destructor(struct share_mode_lock *lck)
                TALLOC_FREE(static_share_mode_record);
        }
 
-       if (static_share_mode_data->num_share_modes != 0) {
+       if (static_share_mode_data->have_share_modes) {
                /*
                 * This is worth keeping. Without share modes,
                 * share_mode_data_store above has left nothing in the
@@ -815,7 +815,7 @@ NTSTATUS share_mode_wakeup_waiters(struct file_id id)
 
 bool share_mode_have_entries(struct share_mode_lock *lck)
 {
-       return (lck->data->num_share_modes != 0);
+       return lck->data->have_share_modes;
 }
 
 struct share_mode_watch_state {
@@ -1374,7 +1374,7 @@ bool share_mode_cleanup_disconnected(struct file_id fid,
                goto done;
        }
 
-       data->num_share_modes = 0;
+       data->have_share_modes = false;
        data->modified = true;
 
        ret = true;
@@ -1650,7 +1650,7 @@ bool set_share_mode(struct share_mode_lock *lck,
        }
 
        if (state.created_share_mode_record) {
-               d->num_share_modes = 1;
+               d->have_share_modes = true;
                d->modified = true;
        }
 
@@ -1799,7 +1799,7 @@ static void share_mode_forall_entries_fn(
 
        if (num_share_modes == 0) {
                if (data.dsize != 0) {
-                       d->num_share_modes = 0;
+                       d->have_share_modes = false;
                        d->modified = true;
                }
                status = dbwrap_record_delete(rec);
@@ -2028,6 +2028,7 @@ static bool share_mode_entry_do(
                .private_data = private_data,
        };
        NTSTATUS status;
+       bool have_share_modes;
 
        status = dbwrap_do_locked(
                share_entries_db,
@@ -2045,8 +2046,9 @@ static bool share_mode_entry_do(
                return false;
        }
 
-       if (d->num_share_modes != state.num_share_modes) {
-               d->num_share_modes = state.num_share_modes;
+       have_share_modes = (state.num_share_modes != 0);
+       if (d->have_share_modes != have_share_modes) {
+               d->have_share_modes = have_share_modes;
                d->modified = true;
        }
 
@@ -2306,7 +2308,7 @@ bool reset_share_mode_entry(
                            nt_errstr(state.status));
                return false;
        }
-       d->num_share_modes = 1;
+       d->have_share_modes = true;
 
        return true;
 }