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

Kevin Harwell asteriskteam at digium.com
Tue Dec 14 18:11:08 CST 2021


Kevin Harwell has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/17677 )

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(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  Kevin Harwell: Looks good to me, approved; Approved for Submit



diff --git a/main/app.c b/main/app.c
index c20e370..5be8457 100644
--- a/main/app.c
+++ b/main/app.c
@@ -2937,6 +2937,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/+/17677
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 18
Gerrit-Change-Id: Id029274a57135caca193c913307a63fd75e24679
Gerrit-Change-Number: 17677
Gerrit-PatchSet: 2
Gerrit-Owner: N A <mail at interlinked.x10host.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: Joshua Colp <jcolp at sangoma.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20211214/4aabf664/attachment.html>


More information about the asterisk-code-review mailing list