rpc_server: Simplify dcesrv_handle_lookup()
authorVolker Lendecke <vl@samba.org>
Mon, 20 Sep 2021 14:42:08 +0000 (16:42 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 24 Sep 2021 23:55:32 +0000 (23:55 +0000)
Reduce indentation with a "break;" from the loop, best reviewed with
git show -b

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
librpc/rpc/dcesrv_handles.c

index cb8b70300cc0ff52f89a15407beadf69b495e717..da1f00f5b676e8d2b35b3114cd4921df8760344e 100644 (file)
@@ -116,28 +116,36 @@ struct dcesrv_handle *dcesrv_handle_lookup(struct dcesrv_call_state *call,
        for (h=context->conn->assoc_group->handles; h; h=h->next) {
                if (h->wire_handle.handle_type == p->handle_type &&
                    GUID_equal(&p->uuid, &h->wire_handle.uuid)) {
-                       if (!dom_sid_equal(&h->sid, sid)) {
-                               struct dom_sid_buf buf1, buf2;
-                               DBG_ERR("Attempt to use invalid sid %s - %s\n",
-                                       dom_sid_str_buf(&h->sid, &buf1),
-                                       dom_sid_str_buf(sid, &buf2));
-                               return NULL;
-                       }
-                       if (call->auth_state->auth_level < h->min_auth_level) {
-                               DEBUG(0,(__location__ ": Attempt to use invalid auth_level %u < %u\n",
-                                        call->auth_state->auth_level,
-                                        h->min_auth_level));
-                               return NULL;
-                       }
-                       if (h->iface != context->iface) {
-                               DEBUG(0,(__location__ ": Attempt to use invalid iface\n"));
-                               return NULL;
-                       }
-                       return h;
+                       break;
                }
        }
 
-       return NULL;
+       if (h == NULL) {
+               /* not found */
+               return NULL;
+       }
+
+       if (!dom_sid_equal(&h->sid, sid)) {
+               struct dom_sid_buf buf1, buf2;
+               DBG_ERR("Attempt to use invalid sid %s - %s\n",
+                       dom_sid_str_buf(&h->sid, &buf1),
+                       dom_sid_str_buf(sid, &buf2));
+               return NULL;
+       }
+
+       if (call->auth_state->auth_level < h->min_auth_level) {
+               DBG_ERR("Attempt to use invalid auth_level %u < %u\n",
+                       call->auth_state->auth_level,
+                       h->min_auth_level);
+               return NULL;
+       }
+
+       if (h->iface != context->iface) {
+               DBG_ERR("Attempt to use invalid iface\n");
+               return NULL;
+       }
+
+       return h;
 }
 
 struct dcesrv_iface_state {