[PATCH] Fix an assertion check
Jeremy Allison
jra at samba.org
Fri Jul 27 22:18:26 UTC 2018
On Fri, Jul 27, 2018 at 12:17:05PM +0530, Anoop C S via samba-technical wrote:
> Hi,
>
> Attached patch fixes the assertion check while reducing the lock reference count. If it is the right
> thing to do we may also consider changing the assertion check while increasing the same lock
> reference count inside increment_lock_ref_count():
>
> SMB_ASSERT(lock_ref_count < (INT32_MAX - 1))
>
> Also the DEBUG statement[inside increment_lock_ref_count() and decrement_lock_ref_count()] prints
> the old reference count value instead of the new one.
>
> Thanks,
> Anoop C S.
This patch is correct. Reviewed-by: Jeremy Allison <jra at samba.org>
Can I get a second Team reviewer ?
Thanks,
Jeremy.
> From 406ee976bd4ea407d08f259785f1ec69ebe07b6c Mon Sep 17 00:00:00 2001
> From: Anoop C S <anoopcs at redhat.com>
> Date: Fri, 27 Jul 2018 11:50:39 +0530
> Subject: [PATCH] s3/locking: Fix assertion check on lock reference count
>
> lock_ref_count will always hold the old value prior to change. Thus it
> would mean that if lock_ref_count is 0 the new value is already -1 which
> is not expected here. Therefore it is better to make sure that it is
> always greater than 0 rather than >= 0.
>
> Signed-off-by: Anoop C S <anoopcs at redhat.com>
> ---
> source3/locking/posix.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/source3/locking/posix.c b/source3/locking/posix.c
> index 0b627aaa3e5..13992663280 100644
> --- a/source3/locking/posix.c
> +++ b/source3/locking/posix.c
> @@ -454,7 +454,7 @@ static void decrement_lock_ref_count(const files_struct *fsp)
> &lock_ref_count, -1);
>
> SMB_ASSERT(NT_STATUS_IS_OK(status));
> - SMB_ASSERT(lock_ref_count >= 0);
> + SMB_ASSERT(lock_ref_count > 0);
>
> DEBUG(10,("lock_ref_count for file %s = %d\n",
> fsp_str_dbg(fsp), (int)lock_ref_count));
> --
> 2.17.1
>
More information about the samba-technical
mailing list