From 29924a1c128739dd405d5463ee03458382f2f403 Mon Sep 17 00:00:00 2001 From: Enji Cooper Date: Sat, 22 Apr 2017 22:34:45 +0000 Subject: [PATCH] gctl_test_helper: add diagnostic output for parse_retval(..) This will help end-users better diagnose issues with the function. MFC after: 5 weeks Sponsored by: Dell EMC Isilon --- tools/regression/geom_gpt/gctl_test_helper.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/regression/geom_gpt/gctl_test_helper.c b/tools/regression/geom_gpt/gctl_test_helper.c index ac5ee4a637b3..48440d037a9f 100644 --- a/tools/regression/geom_gpt/gctl_test_helper.c +++ b/tools/regression/geom_gpt/gctl_test_helper.c @@ -29,6 +29,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include @@ -113,7 +114,7 @@ main(int argc, char *argv[]) struct gctl_req *req; char *param, *value; const char *s; - int c, len; + int c, len, parse_retval; req = gctl_get_handle(); assert(req != NULL); @@ -132,8 +133,9 @@ main(int argc, char *argv[]) } } - while (optind < argc) { - if (!parse(argv[optind++], ¶m, &value, &len)) { + for (; optind < argc; optind++) { + parse_retval = parse(argv[optind], ¶m, &value, &len); + if (parse_retval == 0) { if (len > 0) { rv = malloc(sizeof(struct retval)); assert(rv != NULL); @@ -144,7 +146,9 @@ main(int argc, char *argv[]) gctl_rw_param(req, param, len, value); } else gctl_ro_param(req, param, -1, value); - } + } else + warnc(parse_retval, "failed to parse argument (%s)", + argv[optind]); } if (verbose)