smbd: Use find_share_mode_lease() in downgrade_share_lease
authorVolker Lendecke <vl@samba.org>
Fri, 14 Sep 2018 11:30:43 +0000 (13:30 +0200)
committerStefan Metzmacher <metze@samba.org>
Tue, 2 Oct 2018 16:13:20 +0000 (18:13 +0200)
Simple simplification: In locking/ we did not have the direct
reference to find_share_mode_lock.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source3/smbd/oplock.c

index 57e4e699c4a6bfcd7c73f5c5130ee6f6a9369629..fdb87314d7253baa73ad9c38eded9c3cf8742978 100644 (file)
@@ -525,24 +525,18 @@ static NTSTATUS downgrade_share_lease(struct smbd_server_connection *sconn,
 {
        struct share_mode_data *d = lck->data;
        struct share_mode_lease *l;
 {
        struct share_mode_data *d = lck->data;
        struct share_mode_lease *l;
-       uint32_t i;
+       int idx;
 
        *_l = NULL;
 
 
        *_l = NULL;
 
-       for (i=0; i<d->num_leases; i++) {
-               if (smb2_lease_equal(&sconn->client->connections->smb2.client.guid,
-                                    key,
-                                    &d->leases[i].client_guid,
-                                    &d->leases[i].lease_key)) {
-                       break;
-               }
-       }
-       if (i == d->num_leases) {
+       idx = find_share_mode_lease(
+               d, &sconn->client->connections->smb2.client.guid, key);
+       if (idx == -1) {
                DEBUG(10, ("lease not found\n"));
                return NT_STATUS_INVALID_PARAMETER;
        }
 
                DEBUG(10, ("lease not found\n"));
                return NT_STATUS_INVALID_PARAMETER;
        }
 
-       l = &d->leases[i];
+       l = &d->leases[idx];
 
        if (!l->breaking) {
                DBG_WARNING("Attempt to break from %"PRIu32" to %"PRIu32" - "
 
        if (!l->breaking) {
                DBG_WARNING("Attempt to break from %"PRIu32" to %"PRIu32" - "