From: Volker Lendecke Date: Mon, 11 Jan 2021 20:25:40 +0000 (+0100) Subject: rpc_server: Simplify find_policy_by_hnd_internal() X-Git-Tag: samba-4.14.0rc1~51 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dcc8f37af148df11ebc848013933967da45b0698;p=thirdparty%2Fsamba.git rpc_server: Simplify find_policy_by_hnd_internal() Best viewed with "git show -b". Use the typical pattern of an early error return. Signed-off-by: Volker Lendecke Reviewed-by: Samuel Cabrero --- diff --git a/source3/rpc_server/rpc_handles.c b/source3/rpc_server/rpc_handles.c index d897e0caabe..45968746440 100644 --- a/source3/rpc_server/rpc_handles.c +++ b/source3/rpc_server/rpc_handles.c @@ -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; } /****************************************************************************