Change in ...libosmocore[master]: vty: command.c: Fix is_cmd_ambiguous() returning always 0

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

pespin gerrit-no-reply at lists.osmocom.org
Wed Jun 12 09:38:28 UTC 2019


pespin has submitted this change and it was merged. ( https://gerrit.osmocom.org/c/libosmocore/+/14422 )

Change subject: vty: command.c: Fix is_cmd_ambiguous() returning always 0
......................................................................

vty: command.c: Fix is_cmd_ambiguous() returning always 0

inner block defined variable "enum match_type ret" was being masking
outter block variable "int ret = 0". The ret variable was being given
non zero values only inside the inner block, so that change was done on
the inner variable and not the outer one, which is returned.

Fixes: 5314c513f23688462d7f7937e5ae5e0d5cd4548e
Change-Id: Iec87d7db49a096d07e38ff8a060b923a52bfd6ba
---
M src/vty/command.c
M tests/tdef/tdef_vty_test_config_root.vty
M tests/vty/vty_transcript_test.vty
3 files changed, 14 insertions(+), 43 deletions(-)

Approvals:
  Jenkins Builder: Verified
  fixeria: Looks good to me, approved
  osmith: Looks good to me, approved



diff --git a/src/vty/command.c b/src/vty/command.c
index 6380487..e9690bb 100644
--- a/src/vty/command.c
+++ b/src/vty/command.c
@@ -1521,7 +1521,7 @@
 				if (!desc)
 					continue;
 
-				enum match_type ret;
+				enum match_type mtype;
 				const char *str = desc->cmd;
 
 				if (CMD_OPTION(str)) {
@@ -1573,10 +1573,10 @@
 						match++;
 					break;
 				case ipv6_prefix_match:
-					if ((ret =
+					if ((mtype =
 					     cmd_ipv6_prefix_match
 					     (command)) != no_match) {
-						if (ret == partly_match) {
+						if (mtype == partly_match) {
 							ret = 2;	/* There is incomplete match. */
 							goto free_and_return;
 						}
@@ -1590,10 +1590,10 @@
 						match++;
 					break;
 				case ipv4_prefix_match:
-					if ((ret =
+					if ((mtype =
 					     cmd_ipv4_prefix_match
 					     (command)) != no_match) {
-						if (ret == partly_match) {
+						if (mtype == partly_match) {
 							ret = 2;	/* There is incomplete match. */
 							goto free_and_return;
 						}
diff --git a/tests/tdef/tdef_vty_test_config_root.vty b/tests/tdef/tdef_vty_test_config_root.vty
index e7c96ca..8613ff3 100644
--- a/tests/tdef/tdef_vty_test_config_root.vty
+++ b/tests/tdef/tdef_vty_test_config_root.vty
@@ -115,32 +115,13 @@
 % Invalid T timer argument (should be 'T1234' or 'X1234'): 'T-123'
 
 tdef_vty_test(config)# do show timer t
-tea: T1 = 50 s	Water Boiling Timeout (default: 50 s)
-tea: T2 = 300 s	Tea brewing (default: 300 s)
-tea: T3 = 5 m	Let tea cool down before drinking (default: 5 m)
-tea: T4 = 20 m	Forgot to drink tea while it's warm (default: 20 m)
-test: T1 = 100 s	Testing a hundred seconds (default: 100 s)
-test: T2 = 100 ms	Testing a hundred milliseconds (default: 100 ms)
-test: T3 = 100 m	Testing a hundred minutes (default: 100 m)
-test: T4 = 100	Testing a hundred potatoes (default: 100)
-test: T2147483647 = 4294967295 m	Very large (default: 4294967295 m)
-test: X23 = 239471 s	Negative T number (default: 239471 s)
+% Ambiguous command.
 
 tdef_vty_test(config)# do show timer te
-tea: T1 = 50 s	Water Boiling Timeout (default: 50 s)
-tea: T2 = 300 s	Tea brewing (default: 300 s)
-tea: T3 = 5 m	Let tea cool down before drinking (default: 5 m)
-tea: T4 = 20 m	Forgot to drink tea while it's warm (default: 20 m)
-test: T1 = 100 s	Testing a hundred seconds (default: 100 s)
-test: T2 = 100 ms	Testing a hundred milliseconds (default: 100 ms)
-test: T3 = 100 m	Testing a hundred minutes (default: 100 m)
-test: T4 = 100	Testing a hundred potatoes (default: 100)
-test: T2147483647 = 4294967295 m	Very large (default: 4294967295 m)
-test: X23 = 239471 s	Negative T number (default: 239471 s)
+% Ambiguous command.
 
 tdef_vty_test(config)# do show timer te T2
-tea: T2 = 300 s	Tea brewing (default: 300 s)
-test: T2 = 100 ms	Testing a hundred milliseconds (default: 100 ms)
+% Ambiguous command.
 
 
 tdef_vty_test(config)# timer tea 3 30
@@ -174,20 +155,10 @@
 tea: T4 = 20 m	Forgot to drink tea while it's warm (default: 20 m)
 
 tdef_vty_test(config)# timer t
-tea: T1 = 50 s	Water Boiling Timeout (default: 50 s)
-tea: T2 = 300 s	Tea brewing (default: 300 s)
-tea: T3 = 32 m	Let tea cool down before drinking (default: 5 m)
-tea: T4 = 20 m	Forgot to drink tea while it's warm (default: 20 m)
-test: T1 = 100 s	Testing a hundred seconds (default: 100 s)
-test: T2 = 100 ms	Testing a hundred milliseconds (default: 100 ms)
-test: T3 = 100 m	Testing a hundred minutes (default: 100 m)
-test: T4 = 100	Testing a hundred potatoes (default: 100)
-test: T2147483647 = 4294967295 m	Very large (default: 4294967295 m)
-test: X23 = 239471 s	Negative T number (default: 239471 s)
+% Ambiguous command.
 
 tdef_vty_test(config)# timer te T2
-tea: T2 = 300 s	Tea brewing (default: 300 s)
-test: T2 = 100 ms	Testing a hundred milliseconds (default: 100 ms)
+% Ambiguous command.
 
 tdef_vty_test(config)# timer test T2 100
 
@@ -195,7 +166,7 @@
 % Error: no timers found
 
 tdef_vty_test(config)# timer te T2 100
-% Error: no timers found
+% Ambiguous command.
 
 
 tdef_vty_test(config)# do show timer software
diff --git a/tests/vty/vty_transcript_test.vty b/tests/vty/vty_transcript_test.vty
index 27dacdc..5ed3c1d 100644
--- a/tests/vty/vty_transcript_test.vty
+++ b/tests/vty/vty_transcript_test.vty
@@ -19,7 +19,7 @@
 ok argc=1 o
 
 vty_transcript_test> multi0 t
-ok argc=1 t
+% Ambiguous command.
 
 vty_transcript_test> multi0 th
 ok argc=1 th
@@ -42,7 +42,7 @@
 ok argc=1 o
 
 vty_transcript_test> multi1 t
-ok argc=1 t
+% Ambiguous command.
 
 vty_transcript_test> multi1 th
 ok argc=1 th
@@ -74,4 +74,4 @@
 ok argc=1 on
 
 vty_transcript_test> multi2 t
-ok argc=1 t
+% Ambiguous command.

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Iec87d7db49a096d07e38ff8a060b923a52bfd6ba
Gerrit-Change-Number: 14422
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190612/ba2424e1/attachment.htm>


More information about the gerrit-log mailing list