summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/vty.c9
-rw-r--r--lib/vty.h2
-rw-r--r--ospfd/ospf_vty.c8
-rw-r--r--pimd/pim_cmd.c2
4 files changed, 12 insertions, 9 deletions
diff --git a/lib/vty.c b/lib/vty.c
index d6a0dba206..c0d396ebdc 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -343,11 +343,14 @@ int vty_json_no_pretty(struct vty *vty, struct json_object *json)
return vty_json_helper(vty, json, JSON_C_TO_STRING_NOSLASHESCAPE);
}
-void vty_json_empty(struct vty *vty)
+void vty_json_empty(struct vty *vty, struct json_object *json)
{
- json_object *json = json_object_new_object();
+ json_object *jsonobj = json;
- vty_json(vty, json);
+ if (!json)
+ jsonobj = json_object_new_object();
+
+ vty_json(vty, jsonobj);
}
/* Output current time to the vty. */
diff --git a/lib/vty.h b/lib/vty.h
index 560748d91d..40b413d4fa 100644
--- a/lib/vty.h
+++ b/lib/vty.h
@@ -362,7 +362,7 @@ extern bool vty_set_include(struct vty *vty, const char *regexp);
*/
extern int vty_json(struct vty *vty, struct json_object *json);
extern int vty_json_no_pretty(struct vty *vty, struct json_object *json);
-extern void vty_json_empty(struct vty *vty);
+extern void vty_json_empty(struct vty *vty, struct json_object *json);
/* post fd to be passed to the vtysh client
* fd is owned by the VTY code after this and will be closed when done
*/
diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c
index f92be3fca5..6fbbe4059e 100644
--- a/ospfd/ospf_vty.c
+++ b/ospfd/ospf_vty.c
@@ -5496,7 +5496,7 @@ DEFPY(show_ip_ospf_neighbor_id,
"%% OSPF is not enabled in vrf %s\n",
vrf_name);
else
- vty_json_empty(vty);
+ vty_json_empty(vty, NULL);
return CMD_SUCCESS;
}
ret = show_ip_ospf_neighbor_id_common(
@@ -5997,7 +5997,7 @@ DEFPY(show_ip_ospf_neighbor_int,
if (!ospf || !ospf->oi_running) {
if (json)
- vty_json_empty(vty);
+ vty_json_empty(vty, NULL);
return ret;
}
@@ -6007,7 +6007,7 @@ DEFPY(show_ip_ospf_neighbor_int,
ifp = if_lookup_by_name(ifname, vrf_id);
if (!ifp) {
if (json)
- vty_json_empty(vty);
+ vty_json_empty(vty, NULL);
else
vty_out(vty, "No such interface.\n");
return ret;
@@ -6044,7 +6044,7 @@ DEFPY(show_ip_ospf_neighbor_int_detail,
"%% OSPF is not enabled in vrf %s\n",
vrf_name);
else
- vty_json_empty(vty);
+ vty_json_empty(vty, NULL);
return CMD_SUCCESS;
}
return show_ip_ospf_neighbor_int_detail_common(
diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c
index 2e90cf9053..628a445945 100644
--- a/pimd/pim_cmd.c
+++ b/pimd/pim_cmd.c
@@ -78,7 +78,7 @@ static struct vrf *pim_cmd_lookup_vrf(struct vty *vty, struct cmd_token *argv[],
if (!vrf) {
if (uj)
- vty_json_empty(vty);
+ vty_json_empty(vty, NULL);
else
vty_out(vty, "Specified VRF: %s does not exist\n",
argv[*idx]->arg);