[Skiboot] [PATCH RFC 01/12] opal-prd: Simplify optind handling
Jeremy Kerr
jk at ozlabs.org
Thu May 25 17:05:44 AEST 2017
Increment once, rather than having to use 'optind + 1' on every
subsequent usage.
Signed-off-by: Jeremy Kerr <jk at ozlabs.org>
---
external/opal-prd/opal-prd.c | 18 +++++++++---------
1 file 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;
--
2.7.4
More information about the Skiboot
mailing list