From: Volker Lendecke Date: Tue, 5 Sep 2023 12:40:30 +0000 (+0200) Subject: smbd: Remove variable "accmode" from open_file() X-Git-Tag: tevent-0.16.0~231 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3f4c937dcf92fb875bb178a142526b31502cd180;p=thirdparty%2Fsamba.git smbd: Remove variable "accmode" from open_file() 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 Reviewed-by: Ralph Boehme --- diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 72ce0bf8e49..be42f9430f1 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -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;