[Asterisk-code-review] app.c: Throw warnings for nonexistent options (asterisk[19])

N A asteriskteam at digium.com
Mon Dec 13 07:54:04 CST 2021


N A has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/17678 )


Change subject: app.c: Throw warnings for nonexistent options
......................................................................

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
---
M main/app.c
1 file changed, 3 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/78/17678/1

diff --git a/main/app.c b/main/app.c
index 3263579..df6ffa2 100644
--- a/main/app.c
+++ b/main/app.c
@@ -2814,6 +2814,9 @@
 		} 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 {

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/17678
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 19
Gerrit-Change-Id: Id029274a57135caca193c913307a63fd75e24679
Gerrit-Change-Number: 17678
Gerrit-PatchSet: 1
Gerrit-Owner: N A <mail at interlinked.x10host.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20211213/99a20cab/attachment-0001.html>


More information about the asterisk-code-review mailing list