diff options
-rw-r--r-- | lib/ferr.c | 7 | ||||
-rw-r--r-- | lib/ferr.h | 8 | ||||
-rw-r--r-- | vtysh/vtysh.c | 3 |
3 files changed, 12 insertions, 6 deletions
diff --git a/lib/ferr.c b/lib/ferr.c index d09c41fae..3e56d38ae 100644 --- a/lib/ferr.c +++ b/lib/ferr.c @@ -132,6 +132,7 @@ void ferr_ref_display(struct vty *vty, uint32_t code, bool json) for (ALL_LIST_ELEMENTS_RO(errlist, ln, ref)) { if (json) { char key[11]; + snprintf(key, sizeof(key), "%"PRIu32, ref->code); obj = json_object_new_object(); json_object_string_add(obj, "title", ref->title); @@ -143,14 +144,15 @@ void ferr_ref_display(struct vty *vty, uint32_t code, bool json) } else { char pbuf[256]; char ubuf[256]; + snprintf(pbuf, sizeof(pbuf), "\nError %"PRIu32" - %s", code, ref->title); memset(ubuf, '=', strlen(pbuf)); ubuf[sizeof(ubuf) - 1] = '\0'; vty_out(vty, "%s\n%s\n", pbuf, ubuf); - vty_out(vty, "Description:\n%s\n\nRecommendation:\n%s\n", - ref->description, ref->suggestion); + vty_out(vty, "Description:\n%s\n\n", ref->description); + vty_out(vty, "Recommendation:\n%s\n", ref->suggestion); } } @@ -175,6 +177,7 @@ DEFUN_NOSH(show_error_code, { bool json = strmatch(argv[argc-1]->text, "json"); uint32_t arg = 0; + if (!strmatch(argv[2]->text, "all")) arg = strtoul(argv[2]->arg, NULL, 10); diff --git a/lib/ferr.h b/lib/ferr.h index 51fd9e3be..9e31c9a0a 100644 --- a/lib/ferr.h +++ b/lib/ferr.h @@ -146,7 +146,7 @@ struct ferr_ref { void ferr_ref_add(struct ferr_ref *ref); struct ferr_ref *ferr_ref_get(uint32_t code); -void ferr_ref_display(struct vty *, uint32_t code, bool json); +void ferr_ref_display(struct vty *vty, uint32_t code, bool json); /* * This function should be called by the @@ -163,8 +163,10 @@ void ferr_ref_fini(void); */ const struct ferr *ferr_get_last(ferr_r errval); -/* can optionally be called at strategic locations. - * always returns 0. */ +/* + * Can optionally be called at strategic locations. + * Always returns 0. + */ ferr_r ferr_clear(void); /* do NOT call these functions directly. only for macro use! */ diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index 63195806e..ef4d1a083 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -2354,9 +2354,10 @@ DEFUN (vtysh_show_error_code, "Information on all errors\n" JSON_STR) { + char *fcmd = argv_concat(argv, argc, 0); char cmd[256]; int rv; - char *fcmd = argv_concat(argv, argc, 0); + snprintf(cmd, sizeof(cmd), "do %s", fcmd); /* FIXME: Needs to determine which daemon to send to via code ranges */ |