diff options
author | Vadim Yanitskiy <vyanitskiy@sysmocom.de> | 2020-10-02 18:23:38 +0700 |
---|---|---|
committer | fixeria <vyanitskiy@sysmocom.de> | 2020-10-04 20:55:39 +0000 |
commit | 024e1957cc4c39bb30144e2c023151e35df473e1 (patch) | |
tree | 3622d43fa66b8a44439bfa72c286cd3906fc6c7c /src/vty | |
parent | 68c2e7305ac462347af528ba142fae867d014999 (diff) |
vty: check for duplicate flags in application specific attributes
This would facilitate detecting duplicates on early development stages.
Change-Id: I4e27d6e89d3f851b5ea4f00da01e7093afa537b2
Related: SYS#4937
Diffstat (limited to 'src/vty')
-rw-r--r-- | src/vty/vty.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/vty/vty.c b/src/vty/vty.c index 6e7bdcb3..4d511655 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 @@ void vty_init_vtysh(void) /* 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 @@ void vty_init(struct vty_app_info *app_info) 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(); |