From 66964cf6bf6fc6069b6d94e4a1adf973cc07443b Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Wed, 12 Jan 2022 22:50:26 +0200 Subject: [PATCH 1/2] bgpd: Use vty_json() for bgp_print_dampening_parameters() Signed-off-by: Donatas Abraitis --- bgpd/bgp_damp.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/bgpd/bgp_damp.c b/bgpd/bgp_damp.c index 90b7958c43..91e983e5d5 100644 --- a/bgpd/bgp_damp.c +++ b/bgpd/bgp_damp.c @@ -672,10 +672,7 @@ static int bgp_print_dampening_parameters(struct bgp *bgp, struct vty *vty, json_object_int_add(json, "maxSuppressPenalty", bdc->ceiling); - vty_out(vty, "%s\n", - json_object_to_json_string_ext( - json, JSON_C_TO_STRING_PRETTY)); - json_object_free(json); + vty_json(vty, json); } else { vty_out(vty, "Half-life time: %lld min\n", (long long)bdc->half_life / 60); From a38db2fac79ca4c7b7b49046caed4daf728e3bb1 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Wed, 12 Jan 2022 22:51:46 +0200 Subject: [PATCH 2/2] ospfd: Use vty_json() for show_ip_ospf_gr_helper_cmd Signed-off-by: Donatas Abraitis --- ospfd/ospf_vty.c | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 45dbed0abd..fe3aa0346f 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -10350,12 +10350,8 @@ DEFPY (show_ip_ospf_gr_helper, vty, ospf, use_vrf, json, uj, detail); } - if (uj) { - vty_out(vty, "%s\n", - json_object_to_json_string_ext( - json, JSON_C_TO_STRING_PRETTY)); - json_object_free(json); - } + if (uj) + vty_json(vty, json); return ret; } @@ -10364,12 +10360,9 @@ DEFPY (show_ip_ospf_gr_helper, if (ospf == NULL || !ospf->oi_running) { - if (uj) { - vty_out(vty, "%s\n", - json_object_to_json_string_ext( - json, JSON_C_TO_STRING_PRETTY)); - json_object_free(json); - } else + if (uj) + vty_json(vty, json); + else vty_out(vty, "%% OSPF instance not found\n"); return CMD_SUCCESS; @@ -10381,12 +10374,9 @@ DEFPY (show_ip_ospf_gr_helper, if (ospf == NULL || !ospf->oi_running) { - if (uj) { - vty_out(vty, "%s\n", - json_object_to_json_string_ext( - json, JSON_C_TO_STRING_PRETTY)); - json_object_free(json); - } else + if (uj) + vty_json(vty, json); + else vty_out(vty, "%% OSPF instance not found\n"); return CMD_SUCCESS; @@ -10396,11 +10386,8 @@ DEFPY (show_ip_ospf_gr_helper, detail); } - if (uj) { - vty_out(vty, "%s\n", json_object_to_json_string_ext( - json, JSON_C_TO_STRING_PRETTY)); - json_object_free(json); - } + if (uj) + vty_json(vty, json); return CMD_SUCCESS; }