From: Volker Lendecke Date: Thu, 30 May 2019 09:39:10 +0000 (+0200) Subject: smbd: Slightly simplify reply_lockingX() X-Git-Tag: ldb-2.0.5~366 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8e2b40baadc750a78488227c1d99aa261793354f;p=thirdparty%2Fsamba.git smbd: Slightly simplify reply_lockingX() The brltype only depends upon the central locktype, don't calculate it every time in the loop parsing the lock requests Signed-off-by: Volker Lendecke Reviewed-by: Stefan Metzmacher --- diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index a7054c57db7..3ebde444a93 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -8322,6 +8322,7 @@ void reply_lockingX(struct smb_request *req) connection_struct *conn = req->conn; files_struct *fsp; unsigned char locktype; + enum brl_type brltype; unsigned char oplocklevel; uint16_t num_ulocks; uint16_t num_locks; @@ -8474,24 +8475,25 @@ void reply_lockingX(struct smb_request *req) /* Data now points at the beginning of the list of smb_lkrng structs */ + if (locktype & LOCKING_ANDX_SHARED_LOCK) { + if (locktype & LOCKING_ANDX_CANCEL_LOCK) { + brltype = PENDING_READ_LOCK; + } else { + brltype = READ_LOCK; + } + } else { + if (locktype & LOCKING_ANDX_CANCEL_LOCK) { + brltype = PENDING_WRITE_LOCK; + } else { + brltype = WRITE_LOCK; + } + } + for(i = 0; i < (int)num_locks; i++) { locks[i].smblctx = get_lock_pid(data, i, large_file_format); locks[i].count = get_lock_count(data, i, large_file_format); locks[i].offset = get_lock_offset(data, i, large_file_format); - - if (locktype & LOCKING_ANDX_SHARED_LOCK) { - if (locktype & LOCKING_ANDX_CANCEL_LOCK) { - locks[i].brltype = PENDING_READ_LOCK; - } else { - locks[i].brltype = READ_LOCK; - } - } else { - if (locktype & LOCKING_ANDX_CANCEL_LOCK) { - locks[i].brltype = PENDING_WRITE_LOCK; - } else { - locks[i].brltype = WRITE_LOCK; - } - } + locks[i].brltype = brltype; } status = smbd_do_unlocking(req, fsp, num_ulocks, ulocks);