lib, vtysh: fixup style nits for error refs

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
This commit is contained in:
Quentin Young 2018-07-06 16:39:30 +00:00
parent 98c15db655
commit af4d3437ce
3 changed files with 12 additions and 6 deletions

View File

@ -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);

View File

@ -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! */

View File

@ -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 */