aboutsummaryrefslogtreecommitdiffstats
path: root/src/vty/command.c
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2019-06-11 21:04:09 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2019-06-11 21:04:11 +0200
commit4742526645d6137dd90ef369f0415afdb91736dc (patch)
tree0b0695d48f35efe77db5818bf2d0ab5f2efae5e5 /src/vty/command.c
parent186f87826608fe43060f446ae6d171cd7c56d27b (diff)
vty: command.c: Get rid of huge indentation block
Huge conditional block inside foor loop is negated in this patch together with a "continue" keyword. Change-Id: I9715734ed276f002fdc8c3b9742531ad36b2ef9e
Diffstat (limited to 'src/vty/command.c')
-rw-r--r--src/vty/command.c171
1 files changed, 87 insertions, 84 deletions
diff --git a/src/vty/command.c b/src/vty/command.c
index 87f2abc2..6380487e 100644
--- a/src/vty/command.c
+++ b/src/vty/command.c
@@ -1516,97 +1516,100 @@ is_cmd_ambiguous(char *command, vector v, int index, enum match_type type)
descvec = vector_slot(cmd_element->strvec, index);
- for (j = 0; j < vector_active(descvec); j++)
- if ((desc = vector_slot(descvec, j))) {
- enum match_type ret;
- const char *str = desc->cmd;
-
- if (CMD_OPTION(str)) {
- if (!cmd_deopt_ctx)
- cmd_deopt_ctx =
- talloc_named_const(tall_vty_cmd_ctx, 0,
- __func__);
- str = cmd_deopt(cmd_deopt_ctx, str);
- if (str == NULL)
- continue;
- }
+ for (j = 0; j < vector_active(descvec); j++) {
+ desc = vector_slot(descvec, j);
+ if (!desc)
+ continue;
+
+ enum match_type ret;
+ const char *str = desc->cmd;
+
+ if (CMD_OPTION(str)) {
+ if (!cmd_deopt_ctx)
+ cmd_deopt_ctx =
+ talloc_named_const(tall_vty_cmd_ctx, 0,
+ __func__);
+ str = cmd_deopt(cmd_deopt_ctx, str);
+ if (str == NULL)
+ continue;
+ }
- switch (type) {
- case exact_match:
- if (!(CMD_VARIABLE (str))
- && strcmp(command, str) == 0)
- match++;
- break;
- case partly_match:
- if (!(CMD_VARIABLE (str))
- && strncmp(command, str, strlen (command)) == 0)
- {
- if (matched
- && strcmp(matched,
- str) != 0) {
- ret = 1; /* There is ambiguous match. */
- goto free_and_return;
- } else
- matched = str;
- match++;
- }
- break;
- case range_match:
- if (cmd_range_match
- (str, command)) {
- if (matched
- && strcmp(matched,
- str) != 0) {
- ret = 1;
- goto free_and_return;
- } else
- matched = str;
- match++;
- }
- break;
+ switch (type) {
+ case exact_match:
+ if (!(CMD_VARIABLE (str))
+ && strcmp(command, str) == 0)
+ match++;
+ break;
+ case partly_match:
+ if (!(CMD_VARIABLE (str))
+ && strncmp(command, str, strlen (command)) == 0)
+ {
+ if (matched
+ && strcmp(matched,
+ str) != 0) {
+ ret = 1; /* There is ambiguous match. */
+ goto free_and_return;
+ } else
+ matched = str;
+ match++;
+ }
+ break;
+ case range_match:
+ if (cmd_range_match
+ (str, command)) {
+ if (matched
+ && strcmp(matched,
+ str) != 0) {
+ ret = 1;
+ goto free_and_return;
+ } else
+ matched = str;
+ match++;
+ }
+ break;
#ifdef HAVE_IPV6
- case ipv6_match:
- if (CMD_IPV6(str))
- match++;
- break;
- case ipv6_prefix_match:
- if ((ret =
- cmd_ipv6_prefix_match
- (command)) != no_match) {
- if (ret == partly_match) {
- ret = 2; /* There is incomplete match. */
- goto free_and_return;
- }
-
- match++;
+ case ipv6_match:
+ if (CMD_IPV6(str))
+ match++;
+ break;
+ case ipv6_prefix_match:
+ if ((ret =
+ cmd_ipv6_prefix_match
+ (command)) != no_match) {
+ if (ret == partly_match) {
+ ret = 2; /* There is incomplete match. */
+ goto free_and_return;
}
- break;
+
+ match++;
+ }
+ break;
#endif /* HAVE_IPV6 */
- case ipv4_match:
- if (CMD_IPV4(str))
- match++;
- break;
- case ipv4_prefix_match:
- if ((ret =
- cmd_ipv4_prefix_match
- (command)) != no_match) {
- if (ret == partly_match) {
- ret = 2; /* There is incomplete match. */
- goto free_and_return;
- }
-
- match++;
+ case ipv4_match:
+ if (CMD_IPV4(str))
+ match++;
+ break;
+ case ipv4_prefix_match:
+ if ((ret =
+ cmd_ipv4_prefix_match
+ (command)) != no_match) {
+ if (ret == partly_match) {
+ ret = 2; /* There is incomplete match. */
+ goto free_and_return;
}
- break;
- case extend_match:
- if (CMD_VARIABLE (str))
- match++;
- break;
- case no_match:
- default:
- break;
+
+ match++;
}
+ break;
+ case extend_match:
+ if (CMD_VARIABLE (str))
+ match++;
+ break;
+ case no_match:
+ default:
+ break;
}
+ }
if (!match)
vector_slot(v, i) = NULL;
}