From: Volker Lendecke Date: Thu, 17 Dec 2020 11:36:42 +0000 (+0100) Subject: smbd: Simplify share_mode_entry_do() X-Git-Tag: tevent-0.11.0~654 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=581ebbcc312ba88e02a3b2d9a4776d5e6db39135;p=thirdparty%2Fsamba.git smbd: Simplify share_mode_entry_do() 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 Reviewed-by: Jeremy Allison --- diff --git a/source3/locking/share_mode_lock.c b/source3/locking/share_mode_lock.c index d8c5222d70a..7a091637c74 100644 --- a/source3/locking/share_mode_lock.c +++ b/source3/locking/share_mode_lock.c @@ -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);