]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
rpc_server: Simplify find_policy_by_hnd_internal()
authorVolker Lendecke <vl@samba.org>
Mon, 11 Jan 2021 20:25:40 +0000 (21:25 +0100)
committerVolker Lendecke <vl@samba.org>
Thu, 14 Jan 2021 13:29:35 +0000 (13:29 +0000)
Best viewed with "git show -b". Use the typical pattern of an early
error return.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Samuel Cabrero <scabrero@samba.org>
source3/rpc_server/rpc_handles.c

index d897e0caabe82d2c2f171b2b223b43de4d7947e6..459687464401e317b9c828f19708b1ea78d3c04c 100644 (file)
@@ -153,22 +153,23 @@ static struct dcesrv_handle *find_policy_by_hnd_internal(
         * pipes_struct if the handle type does not match
         */
        h = dcesrv_handle_lookup(p->dce_call, hnd, DCESRV_HANDLE_ANY);
-       if (h != NULL) {
-               if (handle_type != DCESRV_HANDLE_ANY &&
-                       h->wire_handle.handle_type != handle_type) {
-                       /* Just return NULL, do not set a fault
-                        * state in pipes_struct */
-                       return NULL;
-               }
-               if (data_p) {
-                       *data_p = h->data;
-               }
-               return h;
+       if (h == NULL) {
+               p->fault_state = DCERPC_FAULT_CONTEXT_MISMATCH;
+               return NULL;
+       }
+
+       if (handle_type != DCESRV_HANDLE_ANY &&
+           h->wire_handle.handle_type != handle_type) {
+               /* Just return NULL, do not set a fault
+                * state in pipes_struct */
+               return NULL;
        }
 
-       p->fault_state = DCERPC_FAULT_CONTEXT_MISMATCH;
+       if (data_p) {
+               *data_p = h->data;
+       }
 
-       return NULL;
+       return h;
 }
 
 /****************************************************************************