diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2017-05-26 12:54:20 +1000 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2017-06-06 17:59:45 +1000 |
commit | b537752cf694dac00871ab66e1ee2b82b61786b1 (patch) | |
tree | 1a2d88bcea71ab119b223ff8c756df23cf10210a /external/opal-prd/opal-prd.c | |
parent | cc7b746192f04df04cce5737771d2e7703006142 (diff) | |
download | skiboot-b537752cf694dac00871ab66e1ee2b82b61786b1.zip skiboot-b537752cf694dac00871ab66e1ee2b82b61786b1.tar.gz skiboot-b537752cf694dac00871ab66e1ee2b82b61786b1.tar.bz2 |
opal-prd: Simplify optind handling
Increment once, rather than having to use 'optind + 1' on every
subsequent usage.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Reviewed-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'external/opal-prd/opal-prd.c')
-rw-r--r-- | external/opal-prd/opal-prd.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/external/opal-prd/opal-prd.c b/external/opal-prd/opal-prd.c index 1723924..93419e3 100644 --- a/external/opal-prd/opal-prd.c +++ b/external/opal-prd/opal-prd.c @@ -2042,6 +2042,7 @@ int main(int argc, char *argv[]) rc = parse_action(argv[optind], &action); if (rc) return EXIT_FAILURE; + optind++; } else { action = ACTION_RUN_DAEMON; } @@ -2057,41 +2058,40 @@ int main(int argc, char *argv[]) rc = run_prd_daemon(ctx); break; case ACTION_OCC_CONTROL: - if (optind + 1 >= argc) { + if (optind >= argc) { pr_log(LOG_ERR, "CTRL: occ command requires " "an argument"); return EXIT_FAILURE; } - rc = send_occ_control(ctx, argv[optind + 1]); + rc = send_occ_control(ctx, argv[optind]); break; case ACTION_ATTR_OVERRIDE: - if (optind + 1 >= argc) { + if (optind >= argc) { pr_log(LOG_ERR, "CTRL: attribute override command " "requires an argument"); return EXIT_FAILURE; } - rc = send_attr_override(ctx, argc - optind - 1, &argv[optind + 1]); + rc = send_attr_override(ctx, argc - optind, &argv[optind]); break; case ACTION_HTMGT_PASSTHRU: - if (optind + 1 >= argc) { + if (optind >= argc) { pr_log(LOG_ERR, "CTRL: htmgt passthru requires at least " "one argument"); return EXIT_FAILURE; } - rc = send_htmgt_passthru(ctx, argc - optind - 1, - &argv[optind + 1]); + rc = send_htmgt_passthru(ctx, argc - optind, &argv[optind]); break; case ACTION_RUN_COMMAND: - if (optind + 1 >= argc) { + if (optind >= argc) { pr_log(LOG_ERR, "CTRL: run command requires " "argument(s)"); return EXIT_FAILURE; } - rc = send_run_command(ctx, argc - optind - 1, &argv[optind + 1]); + rc = send_run_command(ctx, argc - optind, &argv[optind]); break; default: break; |