pespin has submitted this change and it was merged. ( https://gerrit.osmocom.org/c/libosmocore/+/14421 )
Change subject: vty: command.c: Get rid of huge indentation block ...................................................................... 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 --- M src/vty/command.c 1 file changed, 91 insertions(+), 88 deletions(-) Approvals: Jenkins Builder: Verified fixeria: Looks good to me, but someone else must approve osmith: Looks good to me, approved diff --git a/src/vty/command.c b/src/vty/command.c index 87f2abc..6380487 100644 --- a/src/vty/command.c +++ b/src/vty/command.c @@ -1516,97 +1516,100 @@ 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; + for (j = 0; j < vector_active(descvec); j++) { + desc = vector_slot(descvec, j); + if (!desc) + continue; - 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; - } + enum match_type ret; + const char *str = desc->cmd; - 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++; - } - 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++; - } - break; - case extend_match: - if (CMD_VARIABLE (str)) - match++; - break; - case no_match: - default: - break; - } + 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; +#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++; + } + 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++; + } + break; + case extend_match: + if (CMD_VARIABLE (str)) + match++; + break; + case no_match: + default: + break; + } + } if (!match) vector_slot(v, i) = NULL; } -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/14421 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I9715734ed276f002fdc8c3b9742531ad36b2ef9e Gerrit-Change-Number: 14421 Gerrit-PatchSet: 1 Gerrit-Owner: pespin <pes...@sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <axilira...@gmail.com> Gerrit-Reviewer: osmith <osm...@sysmocom.de> Gerrit-Reviewer: pespin <pes...@sysmocom.de> Gerrit-MessageType: merged