]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
rpcclient: Simplify do_cmd
authorVolker Lendecke <vl@samba.org>
Sat, 6 Feb 2021 21:18:27 +0000 (22:18 +0100)
committerJeremy Allison <jra@samba.org>
Tue, 16 Mar 2021 17:09:32 +0000 (17:09 +0000)
Reduce indentation by an early "continue;", simplify if-expression

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

index 0c2594780c9a2ba36b28ecb739526b476f9164c6..b0a36aac757a5c965c3b91594cc75465ab19d740 100644 (file)
@@ -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;
                }
        }