]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Slightly simplify open_file()
authorVolker Lendecke <vl@samba.org>
Fri, 1 Sep 2023 14:31:03 +0000 (16:31 +0200)
committerRalph Boehme <slow@samba.org>
Thu, 5 Oct 2023 12:58:33 +0000 (12:58 +0000)
Replace "truncating" variable reference with what it was defined
as. We use "(flags & O_TRUNC)" a few lines above, so it can't be that
bad.

After we set it to "false" further down, it was never used again.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/open.c

index a6c16da8aa386d368e3440791d186c46b0f7a00e..72ce0bf8e4902e5ca2c059cbcc6e76887af504d5 100644 (file)
@@ -1325,7 +1325,6 @@ static NTSTATUS open_file(struct smb_request *req,
                FILE_EXECUTE |
                SEC_FLAG_SYSTEM_SECURITY;
        bool creating = !file_existed && (flags & O_CREAT);
-       bool truncating = (flags & O_TRUNC);
        bool open_fd = false;
        bool posix_open = (fsp->posix_flags & FSP_POSIX_FLAGS_OPEN);
 
@@ -1384,7 +1383,8 @@ static NTSTATUS open_file(struct smb_request *req,
                local_flags = (flags & ~O_ACCMODE)|O_RDWR;
        }
 
-       if ((open_access_mask & need_fd_mask) || creating || truncating) {
+       if ((open_access_mask & need_fd_mask) || creating ||
+           (flags & O_TRUNC)) {
                open_fd = true;
        }
 
@@ -1402,7 +1402,6 @@ static NTSTATUS open_file(struct smb_request *req,
                if (file_existed && S_ISFIFO(smb_fname->st.st_ex_mode)) {
                        local_flags &= ~O_TRUNC; /* Can't truncate a FIFO. */
                        local_flags |= O_NONBLOCK;
-                       truncating = false;
                }
 #endif