From: Naveen Albert Date: Mon, 13 Dec 2021 00:08:26 +0000 (+0000) Subject: app.c: Throw warnings for nonexistent options X-Git-Tag: 19.2.0-rc1~53 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ee163da56d2c2f2ccc2c092b76bbf90d27625208;p=thirdparty%2Fasterisk.git app.c: Throw warnings for nonexistent options Currently, Asterisk doesn't throw warnings if options are passed into applications that don't accept them. This can confuse users if they're unaware that they are doing something wrong. This adds an additional check to parse_options so that a warning is thrown anytime an option is parsed that doesn't exist in the parsing application, so that users are notified of the invalid usage. ASTERISK-29801 #close Change-Id: Id029274a57135caca193c913307a63fd75e24679 --- diff --git a/main/app.c b/main/app.c index c20e3705d9..5be8457ec3 100644 --- a/main/app.c +++ b/main/app.c @@ -2937,6 +2937,9 @@ static int parse_options(const struct ast_app_option *options, void *_flags, cha } else if (argloc) { args[argloc - 1] = ""; } + if (!options[curarg].flag) { + ast_log(LOG_WARNING, "Unrecognized option: '%c'\n", curarg); + } if (flaglen == 32) { ast_set_flag(flags, options[curarg].flag); } else {