From 32d5f1db859f69a3cdd1fb50907ece4dfa320eee Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sat, 11 May 2019 11:21:00 +1000 Subject: [PATCH] [common] validate all options including defaults --- common/src/option.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/common/src/option.c b/common/src/option.c index 733dafe2..7bdb14e3 100644 --- a/common/src/option.c +++ b/common/src/option.c @@ -197,20 +197,26 @@ bool option_parse(int argc, char * argv[]) } free(arg); + } + // validate the option values + bool ok = true; + for(int i = 0; i < state.oCount; ++i) + { + struct Option * o = &state.options[i]; if (o->validator) if (!o->validator(&o->value)) { - DEBUG_ERROR("Invalid value provided to option: %s", argv[a]); + DEBUG_ERROR("Invalid value provided to option %s:%s", o->module, o->name); if (o->printHelp) o->printHelp(); - return false; + ok = false; } } - return true; + return ok; } void option_print()