From 6a76a317793d6ae8fa1ce05f4faacbd0978fd5cb Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 30 Jul 2018 13:03:17 +0200 Subject: [PATCH] smbd: Simplify share_mode_stale_pid This loop does not need to count valid share modes. A single valid one is sufficient for keeping the delete token around Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme --- source3/locking/locking.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/source3/locking/locking.c b/source3/locking/locking.c index b2681208cb8..e9bec6d763e 100644 --- a/source3/locking/locking.c +++ b/source3/locking/locking.c @@ -769,24 +769,20 @@ bool share_mode_stale_pid(struct share_mode_data *d, uint32_t idx) e->stale = true; if (d->num_delete_tokens != 0) { - uint32_t i, num_stale; - - /* - * We cannot have any delete tokens - * if there are no valid share modes. - */ - - num_stale = 0; + uint32_t i; for (i=0; inum_share_modes; i++) { - if (d->share_modes[i].stale) { - num_stale += 1; + bool valid = !d->share_modes[i].stale; + if (valid) { + break; } } - if (num_stale == d->num_share_modes) { + if (i == d->num_share_modes) { /* - * No non-stale share mode found + * No valid (non-stale) share mode found, all + * who might have set the delete token are + * gone. */ TALLOC_FREE(d->delete_tokens); d->num_delete_tokens = 0; -- 2.47.2