]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Simplify share_mode_entry_do()
authorVolker Lendecke <vl@samba.org>
Thu, 17 Dec 2020 11:36:42 +0000 (12:36 +0100)
committerJeremy Allison <jra@samba.org>
Fri, 4 Jun 2021 16:47:34 +0000 (16:47 +0000)
Looking at the logic of "ha[d|ve]_share_mode_entry" d->modified=true
can only happen if we remove the last share mode entry . Make this
more explicit, avoid booleans.

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

index d8c5222d70aab46bb3bf0bfda92ff3c26cddb656..7a091637c74f739000b77a00f51f0ac755940047 100644 (file)
@@ -2170,7 +2170,6 @@ static bool share_mode_entry_do(
        bool modified = false;
        struct share_mode_entry e;
        uint8_t *e_ptr = NULL;
-       bool had_share_entries, have_share_entries;
        NTSTATUS status;
        bool ret = false;
 
@@ -2182,8 +2181,6 @@ static bool share_mode_entry_do(
        }
        DBG_DEBUG("num_share_modes=%zu\n", ltdb->num_share_entries);
 
-       had_share_entries = (ltdb->num_share_entries != 0);
-
        idx = share_mode_entry_find(
                ltdb->share_entries,
                ltdb->num_share_entries,
@@ -2229,6 +2226,14 @@ static bool share_mode_entry_do(
                }
                ltdb->num_share_entries -= 1;
 
+               if (ltdb->num_share_entries == 0) {
+                       /*
+                        * Tell share_mode_lock_destructor() to delete
+                        * the whole record
+                        */
+                       d->modified = true;
+               }
+
                if (DEBUGLEVEL>=10) {
                        DBG_DEBUG("share_mode_entry:\n");
                        NDR_PRINT_DEBUG(share_mode_entry, &e);
@@ -2260,15 +2265,6 @@ static bool share_mode_entry_do(
                goto done;
        }
 
-       have_share_entries = (ltdb->num_share_entries != 0);
-       if (had_share_entries != have_share_entries) {
-               /*
-                * Make share_mode_data_store do the right thing wrt
-                * possibly deleting the locking.tdb record
-                */
-               d->modified = true;
-       }
-
        ret = true;
 done:
        TALLOC_FREE(ltdb);