]> sourceware.org Git - lvm2.git/commitdiff
command: refactor if condition
authorZdenek Kabelac <zkabelac@redhat.com>
Sat, 27 Apr 2024 09:36:42 +0000 (11:36 +0200)
committerZdenek Kabelac <zkabelac@redhat.com>
Sun, 28 Apr 2024 22:13:43 +0000 (00:13 +0200)
tools/command.c

index 37ced6443a6e5ceeba1f1c17f0dedbcd210afc4e..0bc27060919ceb36904083a7dc71ea0da3168c41 100644 (file)
@@ -1947,9 +1947,7 @@ void print_usage(struct command *cmd, int longhelp, int desc_first)
                }
 
                printf_hyphen(')');
-       }
-
-       if (!any_req && cmd->ro_count) {
+       } else  /* !any_req */
                for (ro = 0; ro < cmd->ro_count; ro++) {
                        opt_enum = cmd->required_opt_args[ro].opt;
 
@@ -1966,7 +1964,6 @@ void print_usage(struct command *cmd, int longhelp, int desc_first)
                                _print_usage_def(cmd, opt_enum, &cmd->required_opt_args[ro].def);
                        }
                }
-       }
 
        if (cmd->rp_count) {
                if (any_req)
@@ -1982,9 +1979,6 @@ void print_usage(struct command *cmd, int longhelp, int desc_first)
        if (!longhelp)
                goto done;
 
-       if (!cmd->oo_count)
-               goto op_count;
-
        if (cmd->oo_count) {
                if (cmd->autotype) {
                        printf("\n\t");
@@ -2083,22 +2077,17 @@ void print_usage(struct command *cmd, int longhelp, int desc_first)
                printf("\n\t[ COMMON_OPTIONS ]");
        }
 
- op_count:
-       if (!cmd->op_count)
-               goto done;
-
-       printf("\n\t[");
-
        if (cmd->op_count) {
-               for (op = 0; op < cmd->op_count; op++) {
+               printf("\n\t[");
+
+               for (op = 0; op < cmd->op_count; op++)
                        if (cmd->optional_pos_args[op].def.val_bits) {
                                printf(" ");
                                _print_usage_def(cmd, 0, &cmd->optional_pos_args[op].def);
                        }
-               }
-       }
 
-       printf(" ]");
+               printf(" ]");
+       }
  done:
        printf("\n");
 
This page took 0.034809 seconds and 5 git commands to generate.