]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Slightly simplify reply_lockingX()
authorVolker Lendecke <vl@samba.org>
Thu, 30 May 2019 09:39:10 +0000 (11:39 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 18 Jun 2019 12:54:00 +0000 (12:54 +0000)
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 <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source3/smbd/reply.c

index a7054c57db73d2d689a5a549cd30aacb12a68c45..3ebde444a939c262a3f7258f95781c015c24ca92 100644 (file)
@@ -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);