s3/locking: Fix assertion check on lock reference count
authorAnoop C S <anoopcs@redhat.com>
Fri, 27 Jul 2018 06:20:39 +0000 (11:50 +0530)
committerJeremy Allison <jra@samba.org>
Tue, 31 Jul 2018 02:23:47 +0000 (04:23 +0200)
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@redhat.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Jul 31 04:23:47 CEST 2018 on sn-devel-144

source3/locking/posix.c

index 0b627aaa3e58ed2190a143e3bd028653ad97115c..13992663280387b9d73e2dcbc970c7a90b159153 100644 (file)
@@ -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));
                &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));
 
        DEBUG(10,("lock_ref_count for file %s = %d\n",
                  fsp_str_dbg(fsp), (int)lock_ref_count));