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/.
fixeria gerrit-no-reply at lists.osmocom.orgfixeria has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/20411 ) Change subject: vty: check for duplicate flags in application specific attributes ...................................................................... vty: check for duplicate flags in application specific attributes This would facilitate detecting duplicates on early development stages. Change-Id: I4e27d6e89d3f851b5ea4f00da01e7093afa537b2 Related: SYS#4937 --- M src/vty/vty.c M tests/vty/vty_test.c M tests/vty/vty_test.err 3 files changed, 36 insertions(+), 0 deletions(-) Approvals: laforge: Looks good to me, but someone else must approve pespin: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/vty/vty.c b/src/vty/vty.c index 6e7bdcb..4d51165 100644 --- a/src/vty/vty.c +++ b/src/vty/vty.c @@ -66,6 +66,7 @@ #include <osmocom/vty/command.h> #include <osmocom/vty/buffer.h> #include <osmocom/core/talloc.h> +#include <osmocom/core/utils.h> #ifndef MAXPATHLEN #define MAXPATHLEN 4096 @@ -1794,6 +1795,8 @@ /* Install vty's own commands like `who' command. */ void vty_init(struct vty_app_info *app_info) { + unsigned int i, j; + tall_vty_ctx = talloc_named_const(NULL, 0, "vty"); tall_vty_vec_ctx = talloc_named_const(tall_vty_ctx, 0, "vty_vector"); tall_vty_cmd_ctx = talloc_named_const(tall_vty_ctx, 0, "vty_command"); @@ -1802,6 +1805,19 @@ host.app_info = app_info; + /* Check for duplicate flags in application specific attributes (if any) */ + for (i = 0; i < ARRAY_SIZE(app_info->usr_attr_letters); i++) { + if (app_info->usr_attr_letters[i] == '\0') + continue; + for (j = i + 1; j < ARRAY_SIZE(app_info->usr_attr_letters); j++) { + if (app_info->usr_attr_letters[j] != app_info->usr_attr_letters[i]) + continue; + fprintf(stderr, "Found duplicate flag letter '%c' in application " + "specific attributes (index %u vs %u)! Please fix.\n", + app_info->usr_attr_letters[i], i, j); + } + } + /* For further configuration read, preserve current directory. */ vty_save_cwd(); diff --git a/tests/vty/vty_test.c b/tests/vty/vty_test.c index b2d34ad..1608b83 100644 --- a/tests/vty/vty_test.c +++ b/tests/vty/vty_test.c @@ -513,11 +513,29 @@ destroy_test_vty(&test, vty); } +/* Application specific attributes */ +enum vty_test_attr { + VTY_TEST_ATTR_FOO = 0, + VTY_TEST_ATTR_BAR, + VTY_TEST_ATTR_ZOO, + VTY_TEST_ATTR_FOO_DUP, + VTY_TEST_ATTR_ZOO_DUP, +}; + int main(int argc, char **argv) { struct vty_app_info vty_info = { .name = "VtyTest", .version = 0, + .usr_attr_letters = { + [VTY_TEST_ATTR_FOO] = 'f', + [VTY_TEST_ATTR_BAR] = 'b', + [VTY_TEST_ATTR_ZOO] = 'z', + + /* Duplicate detection check */ + [VTY_TEST_ATTR_FOO_DUP] = 'f', + [VTY_TEST_ATTR_ZOO_DUP] = 'z', + }, }; const struct log_info_cat default_categories[] = {}; diff --git a/tests/vty/vty_test.err b/tests/vty/vty_test.err index 8ad4fd9..25c94e6 100644 --- a/tests/vty/vty_test.err +++ b/tests/vty/vty_test.err @@ -1,3 +1,5 @@ +Found duplicate flag letter 'f' in application specific attributes (index 0 vs 3)! Please fix. +Found duplicate flag letter 'z' in application specific attributes (index 2 vs 4)! Please fix. Got VTY event: 2 Got VTY event: 2 Got VTY event: 2 -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/20411 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I4e27d6e89d3f851b5ea4f00da01e7093afa537b2 Gerrit-Change-Number: 20411 Gerrit-PatchSet: 3 Gerrit-Owner: fixeria <vyanitskiy at sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: dexter <pmaier at sysmocom.de> Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de> Gerrit-Reviewer: laforge <laforge at osmocom.org> 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/20201004/801955f2/attachment.htm>