]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Avoid more assignments within checks (round 2)
authorDonatas Abraitis <donatas.abraitis@gmail.com>
Tue, 29 Jun 2021 11:53:39 +0000 (14:53 +0300)
committerDonatas Abraitis <donatas.abraitis@gmail.com>
Tue, 29 Jun 2021 19:27:50 +0000 (22:27 +0300)
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
bgpd/bgp_aspath.c
bgpd/bgp_mpath.c
bgpd/bgp_route.c
bgpd/bgp_routemap_nb_config.c
bgpd/bgp_updgrp_adv.c
bgpd/bgp_vty.c
bgpd/bgpd.c

index 25109e030b8d705ecb3cc4ae46c86672ae03a97a..3c67017dc7209856f52a995f63c469e25a60119f 100644 (file)
@@ -193,7 +193,8 @@ static struct assegment *assegment_prepend_asns(struct assegment *seg,
        if (num >= AS_SEGMENT_MAX)
                return seg; /* we don't do huge prepends */
 
-       if ((newas = assegment_data_new(seg->length + num)) == NULL)
+       newas = assegment_data_new(seg->length + num);
+       if (newas == NULL)
                return seg;
 
        for (i = 0; i < num; i++)
index d5fce115de4273a39493892a0c7fa60a4cb40b2a..8127428bc71dc8597f1e980cad539a7993e38024 100644 (file)
@@ -411,7 +411,8 @@ static void bgp_path_info_mpath_lb_update(struct bgp_path_info *path, bool set,
 {
        struct bgp_path_info_mpath *mpath;
 
-       if ((mpath = path->mpath) == NULL) {
+       mpath = path->mpath;
+       if (mpath == NULL) {
                if (!set || (cum_bw == 0 && !all_paths_lb))
                        return;
 
index 4637cef3eb8055778ed3727fb0e025164d5c147b..6d6e3a95a64a58709b73790039467d0ffb3fbf7c 100644 (file)
@@ -11643,7 +11643,8 @@ static int bgp_show_route_in_table(struct vty *vty, struct bgp *bgp,
                        if (!table)
                                continue;
 
-                       if ((rm = bgp_node_match(table, &match)) == NULL)
+                       rm = bgp_node_match(table, &match);
+                       if (rm == NULL)
                                continue;
 
                        const struct prefix *rm_p = bgp_dest_get_prefix(rm);
@@ -11735,7 +11736,8 @@ static int bgp_show_route_in_table(struct vty *vty, struct bgp *bgp,
                                json_object_free(json_paths);
                }
        } else {
-               if ((dest = bgp_node_match(rib, &match)) != NULL) {
+               dest = bgp_node_match(rib, &match);
+               if (dest != NULL) {
                        const struct prefix *dest_p = bgp_dest_get_prefix(dest);
                        if (!prefix_check
                            || dest_p->prefixlen == match.prefixlen) {
@@ -14758,7 +14760,8 @@ static int bgp_clear_damp_route(struct vty *vty, const char *view_name,
                        table = bgp_dest_get_bgp_table_info(dest);
                        if (!table)
                                continue;
-                       if ((rm = bgp_node_match(table, &match)) == NULL)
+                       rm = bgp_node_match(table, &match);
+                       if (rm == NULL)
                                continue;
 
                        const struct prefix *rm_p = bgp_dest_get_prefix(dest);
@@ -14782,8 +14785,8 @@ static int bgp_clear_damp_route(struct vty *vty, const char *view_name,
                        bgp_dest_unlock_node(rm);
                }
        } else {
-               if ((dest = bgp_node_match(bgp->rib[afi][safi], &match))
-                   != NULL) {
+               dest = bgp_node_match(bgp->rib[afi][safi], &match);
+               if (dest != NULL) {
                        const struct prefix *dest_p = bgp_dest_get_prefix(dest);
 
                        if (!prefix_check
index e541d117bee8b48447d006642ac5dabf514f2be1..88e3f6438f547299887441b85406f2a3ad6afc05 100644 (file)
@@ -70,8 +70,8 @@ static int bgp_route_match_delete(struct route_map_index *index,
        if (type != RMAP_EVENT_MATCH_DELETED) {
                /* ignore the mundane, the types without any dependency */
                if (arg == NULL) {
-                       if ((tmpstr = route_map_get_match_arg(index, command))
-                                       != NULL)
+                       tmpstr = route_map_get_match_arg(index, command);
+                       if (tmpstr != NULL)
                                dep_name =
                                        XSTRDUP(MTYPE_ROUTE_MAP_RULE, tmpstr);
                } else {
index 18829aa7477a944debe9e28d48da67d9df2f64ff..9c2288cba3999dbbf9dc35e3223a0f4e8913689e 100644 (file)
@@ -572,7 +572,8 @@ void bgp_adj_out_unset_subgroup(struct bgp_dest *dest,
                return;
 
        /* Lookup existing adjacency */
-       if ((adj = adj_lookup(dest, subgrp, addpath_tx_id)) != NULL) {
+       adj = adj_lookup(dest, subgrp, addpath_tx_id);
+       if (adj != NULL) {
                /* Clean up previous advertisement.  */
                if (adj->adv)
                        bgp_advertise_clean_subgroup(subgrp, adj);
index de4f5a59b646a22879b2037143dce70a00a6ea41..d020e14fb373ed5cdd9c3ede6436b932a45434c2 100644 (file)
@@ -1789,9 +1789,8 @@ void cli_show_router_bgp_med_config(struct vty *vty, struct lyd_node *dnode,
                uint32_t med_admin_val;
 
                vty_out(vty, " bgp max-med administrative");
-               if ((med_admin_val =
-                            yang_dnode_get_uint32(dnode, "./max-med-admin"))
-                   != BGP_MAXMED_VALUE_DEFAULT)
+               med_admin_val = yang_dnode_get_uint32(dnode, "./max-med-admin");
+               if (med_admin_val != BGP_MAXMED_VALUE_DEFAULT)
                        vty_out(vty, " %u", med_admin_val);
                vty_out(vty, "\n");
        }
@@ -10120,7 +10119,8 @@ static int bgp_clear_prefix(struct vty *vty, const char *view_name,
                        if (table == NULL)
                                continue;
 
-                       if ((rm = bgp_node_match(table, &match)) != NULL) {
+                       rm = bgp_node_match(table, &match);
+                       if (rm != NULL) {
                                const struct prefix *rm_p =
                                        bgp_dest_get_prefix(rm);
 
@@ -10133,7 +10133,8 @@ static int bgp_clear_prefix(struct vty *vty, const char *view_name,
                        }
                }
        } else {
-               if ((dest = bgp_node_match(rib, &match)) != NULL) {
+               dest = bgp_node_match(rib, &match);
+               if (dest != NULL) {
                        const struct prefix *dest_p = bgp_dest_get_prefix(dest);
 
                        if (dest_p->prefixlen == match.prefixlen) {
index 49562e587467da16e402ae7634cc28841a20ea95..b5eebe8259e748ef0966673c18d1840838a80eea 100644 (file)
@@ -3103,7 +3103,8 @@ static struct bgp *bgp_create(as_t *as, const char *name,
        afi_t afi;
        safi_t safi;
 
-       if ((bgp = XCALLOC(MTYPE_BGP, sizeof(struct bgp))) == NULL)
+       bgp = XCALLOC(MTYPE_BGP, sizeof(struct bgp));
+       if (bgp == NULL)
                return NULL;
 
        if (BGP_DEBUG(zebra, ZEBRA)) {