Skip to content

Commit

Permalink
opal-prd: Simplify optind handling
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
jk-ozlabs authored and stewartsmith committed Jun 6, 2017
1 parent cc7b746 commit b537752
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions external/opal-prd/opal-prd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down

0 comments on commit b537752

Please sign in to comment.