]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Calculate delay_mask only once in delay_for_oplock
authorVolker Lendecke <vl@samba.org>
Fri, 17 May 2019 13:29:59 +0000 (15:29 +0200)
committerJeremy Allison <jra@samba.org>
Thu, 23 May 2019 16:56:17 +0000 (16:56 +0000)
"const" ist just a hint to make sure it's actually not modified inside
the loop

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

index 0a4abe0d820e6c248f0165829bb70f9cb94c2959..8e9de5e11b44ff24649268f65403337e2ba3be66 100644 (file)
@@ -1849,6 +1849,8 @@ static bool delay_for_oplock(files_struct *fsp,
        uint32_t i;
        bool delay = false;
        bool will_overwrite;
+       const uint32_t delay_mask = have_sharing_violation ?
+               SMB2_LEASE_HANDLE : SMB2_LEASE_WRITE;
 
        if ((oplock_request & INTERNAL_OPEN_ONLY) ||
            is_stat_open(fsp->access_mask)) {
@@ -1871,7 +1873,6 @@ static bool delay_for_oplock(files_struct *fsp,
                bool e_is_lease = (e->op_type == LEASE_OPLOCK);
                uint32_t e_lease_type = get_lease_type(d, e);
                uint32_t break_to;
-               uint32_t delay_mask = 0;
                bool lease_is_breaking = false;
 
                if (e_is_lease) {
@@ -1902,12 +1903,6 @@ static bool delay_for_oplock(files_struct *fsp,
                        SMB_ASSERT(NT_STATUS_IS_OK(status));
                }
 
-               if (have_sharing_violation) {
-                       delay_mask = SMB2_LEASE_HANDLE;
-               } else {
-                       delay_mask = SMB2_LEASE_WRITE;
-               }
-
                break_to = e_lease_type & ~delay_mask;
 
                if (will_overwrite) {