From: Volker Lendecke Date: Sat, 6 Feb 2021 21:18:27 +0000 (+0100) Subject: rpcclient: Simplify do_cmd X-Git-Tag: tevent-0.11.0~1530 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cf2a943b8de5428d1fd43f57f1eee397020ef122;p=thirdparty%2Fsamba.git rpcclient: Simplify do_cmd Reduce indentation by an early "continue;", simplify if-expression Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c index 0c2594780c9..b0a36aac757 100644 --- a/source3/rpcclient/rpcclient.c +++ b/source3/rpcclient/rpcclient.c @@ -911,22 +911,25 @@ static NTSTATUS process_cmd(struct user_auth_info *auth_info, /* Walk through a dlist of arrays of commands. */ for (temp_list = cmd_list; temp_list; temp_list = temp_list->next) { - struct cmd_set *temp_set = temp_list->cmd_set; - - while (temp_set->name) { - if (strequal(argv[0], temp_set->name)) { - if (!(temp_set->returntype == RPC_RTYPE_NTSTATUS && temp_set->ntfn ) && - !(temp_set->returntype == RPC_RTYPE_WERROR && temp_set->wfn )) { - fprintf (stderr, "Invalid command\n"); - goto out_free; - } + struct cmd_set *set = temp_list->cmd_set; - result = do_cmd(cli, auth_info, temp_set, - binding, argc, argv); + while (set->name != NULL) { + if (!strequal(argv[0], set->name)) { + set += 1; + continue; + } + if (((set->returntype == RPC_RTYPE_NTSTATUS) && + (set->ntfn == NULL)) || + ((set->returntype == RPC_RTYPE_WERROR) && + (set->wfn == NULL))) { + fprintf (stderr, "Invalid command\n"); goto out_free; } - temp_set++; + + result = do_cmd( + cli, auth_info, set, binding, argc, argv); + goto out_free; } }