-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ttable vty finish #15386
base: master
Are you sure you want to change the base?
Ttable vty finish #15386
Conversation
Consistent pattern was this: out = ttable_dump(tt, "\n"); vty_out(vty, "%s", out); XFREE(MTYPE_TMP, out); ttable_del(tt); Let's just consolidate this pattern into ttable_vty_finish. Since no-one ever used it any other way. Signed-off-by: Donald Sharp <[email protected]>
There is another common pattern in the usage of ttable_vty_finish that is this: if (tt->nrows > 1) { ttable_vty_finish(vty, &tt, "\n"); } else { vty_out(vty, "No configuration transactions to display.\n\n"); ttable_del(tt); } Let's move this into the ttable_vty_finish function and let callers specify the string to use when the table is empty. Signed-off-by: Donald Sharp <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Valid failures though. |
void ttable_vty_finish(struct vty *vty, struct ttable **tt, const char *newline, | ||
const char *display_if_no_rows) | ||
{ | ||
if ((*tt)->nrows > 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't dig too deeply but should this really be > 1
rather than > 0
?
* @param tt - double pointer to the table to dump, this pointer | ||
* is freed. | ||
* @param newline the desired newline sequence to use, null terminated. | ||
* @param display_if_no_rows The string to display if nrows is 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This description is incorrect as it will currently (perhaps erroneously) display the string if nrows is 0 or 1.
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
This PR is stale because it has been open 180 days with no activity. Comment or remove the |
Add a ttable_vty_finish function that encapsulates common coding patterns. See the individual commits for details.