]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: convert from conditional operator to if-then for json changes 2945/head
authorDon Slice <dslice@cumulusnetworks.com>
Fri, 31 Aug 2018 16:32:22 +0000 (16:32 +0000)
committerDon Slice <dslice@cumulusnetworks.com>
Fri, 31 Aug 2018 17:11:23 +0000 (17:11 +0000)
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
bgpd/bgp_vty.c

index ef89981dcd7681bb3e6d4618b3ac8301c255bdd6..95ce0b9ecedf993d2933e177ea817b51026217a2 100644 (file)
@@ -321,11 +321,11 @@ int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty,
                else {
                        *bgp = bgp_lookup_by_name(vrf_name);
                        if (!*bgp) {
-                               vty_out(vty,
-                                       use_json
-                                               ? "{}\n"
-                                               : "View/Vrf specified is unknown: %s\n",
-                                       vrf_name);
+                               if (use_json)
+                                       vty_out(vty, "{}\n");
+                               else
+                                       vty_out(vty, "View/Vrf %s is unknown\n",
+                                               vrf_name);
                                *idx = 0;
                                return 0;
                        }
@@ -333,10 +333,11 @@ int bgp_vty_find_and_parse_afi_safi_bgp(struct vty *vty,
        } else {
                *bgp = bgp_get_default();
                if (!*bgp) {
-                       vty_out(vty,
-                               use_json
-                                       ? "{}\n"
-                                       : "Unable to find default BGP instance\n");
+                       if (use_json)
+                               vty_out(vty, "{}\n");
+                       else
+                               vty_out(vty,
+                                       "Default BGP instance not found\n");
                        *idx = 0;
                        return 0;
                }
@@ -8117,8 +8118,12 @@ static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi,
 
        if (use_json && is_wildcard)
                vty_out(vty, "}\n");
-       else if (!nbr_output)
-               vty_out(vty, use_json ? "{}\n" : "%% No BGP neighbors found\n");
+       else if (!nbr_output) {
+               if (use_json)
+                       vty_out(vty, "{}\n");
+               else
+                       vty_out(vty, "%% No BGP neighbors found\n");
+       }
 }
 
 static void bgp_show_all_instances_summary_vty(struct vty *vty, afi_t afi,
@@ -8176,10 +8181,11 @@ int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi,
                        bgp = bgp_lookup_by_name(name);
 
                        if (!bgp) {
-                               vty_out(vty,
-                                       use_json
-                                               ? "{}\n"
-                                               : "%% BGP instance not found\n");
+                               if (use_json)
+                                       vty_out(vty, "{}\n");
+                               else
+                                       vty_out(vty,
+                                               "%% BGP instance not found\n");
                                return CMD_WARNING;
                        }
 
@@ -8194,8 +8200,10 @@ int bgp_show_summary_vty(struct vty *vty, const char *name, afi_t afi,
        if (bgp)
                bgp_show_summary_afi_safi(vty, bgp, afi, safi, use_json, NULL);
        else {
-               vty_out(vty,
-                       use_json ? "{}\n" : "%% No such BGP instance exist\n");
+               if (use_json)
+                       vty_out(vty, "{}\n");
+               else
+                       vty_out(vty, "%% BGP instance not found\n");
                return CMD_WARNING;
        }
 
@@ -10879,8 +10887,12 @@ static int bgp_show_neighbor_vty(struct vty *vty, const char *name,
                                          json);
                }
                json_object_free(json);
-       } else
-               vty_out(vty, use_json ? "{}\n" : "%% BGP instance not found\n");
+       } else {
+               if (use_json)
+                       vty_out(vty, "{}\n");
+               else
+                       vty_out(vty, "%% BGP instance not found\n");
+       }
 
        return CMD_SUCCESS;
 }