]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Do boolean short-circuiting
authorVolker Lendecke <vl@samba.org>
Mon, 9 Sep 2019 08:42:59 +0000 (10:42 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 10 Sep 2019 23:14:32 +0000 (23:14 +0000)
&= does bitwise AND, and does not do boolean short-circuiting if the
variable is already 0. As has_other_nonposix_opens() might have its
cost, this speeds up closing a handle.

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

index 06d3f81f5a6769fc143c17a226d381743af2f601..9786c826439c500966920bd8f4093149a04e63c4 100644 (file)
@@ -350,9 +350,8 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp,
                }
        }
 
-       delete_file = is_delete_on_close_set(lck, fsp->name_hash);
-
-       delete_file &= !has_other_nonposix_opens(lck, fsp);
+       delete_file = is_delete_on_close_set(lck, fsp->name_hash) &&
+               !has_other_nonposix_opens(lck, fsp);
 
        /*
         * NT can set delete_on_close of the last open
@@ -1156,10 +1155,9 @@ static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp,
                }
        }
 
-       delete_dir = get_delete_on_close_token(lck, fsp->name_hash,
-                                       &del_nt_token, &del_token);
-
-       delete_dir &= !has_other_nonposix_opens(lck, fsp);
+       delete_dir = get_delete_on_close_token(
+               lck, fsp->name_hash, &del_nt_token, &del_token) &&
+               !has_other_nonposix_opens(lck, fsp);
 
        if ((close_type == NORMAL_CLOSE || close_type == SHUTDOWN_CLOSE) &&
                                delete_dir) {