]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Remove variable "accmode" from open_file()
authorVolker Lendecke <vl@samba.org>
Tue, 5 Sep 2023 12:40:30 +0000 (14:40 +0200)
committerRalph Boehme <slow@samba.org>
Thu, 5 Oct 2023 12:58:33 +0000 (12:58 +0000)
We directly look at the flags in many other places in this function,
so do this also for O_ACCMODE for clarity.

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

index 72ce0bf8e4902e5ca2c059cbcc6e76887af504d5..be42f9430f149230234353f058e045388e78214d 100644 (file)
@@ -1315,7 +1315,6 @@ static NTSTATUS open_file(struct smb_request *req,
        connection_struct *conn = fsp->conn;
        struct smb_filename *smb_fname = fsp->fsp_name;
        NTSTATUS status = NT_STATUS_OK;
-       int accmode = (flags & O_ACCMODE);
        int local_flags = flags;
        bool file_existed = VALID_STAT(fsp->fsp_name->st);
        const uint32_t need_fd_mask =
@@ -1350,7 +1349,8 @@ static NTSTATUS open_file(struct smb_request *req,
 
        if (!CAN_WRITE(conn)) {
                /* It's a read-only share - fail if we wanted to write. */
-               if(accmode != O_RDONLY || (flags & O_TRUNC) || (flags & O_APPEND)) {
+               if ((flags & O_ACCMODE) != O_RDONLY || (flags & O_TRUNC) ||
+                   (flags & O_APPEND)) {
                        DEBUG(3,("Permission denied opening %s\n",
                                 smb_fname_str_dbg(smb_fname)));
                        return NT_STATUS_ACCESS_DENIED;
@@ -1377,7 +1377,8 @@ static NTSTATUS open_file(struct smb_request *req,
         * as we always opened files read-write in that release. JRA.
         */
 
-       if ((accmode == O_RDONLY) && ((flags & O_TRUNC) == O_TRUNC)) {
+       if (((flags & O_ACCMODE) == O_RDONLY) &&
+           ((flags & O_TRUNC) == O_TRUNC)) {
                DEBUG(10,("open_file: truncate requested on read-only open "
                          "for file %s\n", smb_fname_str_dbg(smb_fname)));
                local_flags = (flags & ~O_ACCMODE)|O_RDWR;