summaryrefslogtreecommitdiffstats
path: root/bgpd
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_advertise.c10
-rw-r--r--bgpd/bgp_aspath.c6
-rw-r--r--bgpd/bgp_attr.c6
-rw-r--r--bgpd/bgp_attr_evpn.c4
-rw-r--r--bgpd/bgp_clist.c9
-rw-r--r--bgpd/bgp_community.c9
-rw-r--r--bgpd/bgp_ecommunity.c9
-rw-r--r--bgpd/bgp_encap_tlv.c3
-rw-r--r--bgpd/bgp_evpn.c10
-rw-r--r--bgpd/bgp_filter.c6
-rw-r--r--bgpd/bgp_labelpool.c6
-rw-r--r--bgpd/bgp_lcommunity.c17
-rw-r--r--bgpd/bgp_mpath.c2
-rw-r--r--bgpd/bgp_pbr.c6
-rw-r--r--bgpd/bgp_rd.c3
-rw-r--r--bgpd/bgp_route.c43
-rw-r--r--bgpd/bgp_routemap.c19
-rw-r--r--bgpd/bgp_snmp.c14
-rw-r--r--bgpd/bgp_updgrp.c36
-rw-r--r--bgpd/bgp_updgrp_packet.c3
-rw-r--r--bgpd/bgp_vty.c6
-rw-r--r--bgpd/bgp_zebra.c9
-rw-r--r--bgpd/bgpd.c50
-rw-r--r--bgpd/rfapi/bgp_rfapi_cfg.c9
-rw-r--r--bgpd/rfapi/rfapi_import.c2
-rw-r--r--bgpd/rfapi/vnc_debug.c2
-rw-r--r--bgpd/rfapi/vnc_zebra.c12
27 files changed, 105 insertions, 206 deletions
diff --git a/bgpd/bgp_advertise.c b/bgpd/bgp_advertise.c
index 208a2947e..05eeeca15 100644
--- a/bgpd/bgp_advertise.c
+++ b/bgpd/bgp_advertise.c
@@ -45,8 +45,8 @@
peer. */
struct bgp_advertise_attr *baa_new(void)
{
- return (struct bgp_advertise_attr *)XCALLOC(
- MTYPE_BGP_ADVERTISE_ATTR, sizeof(struct bgp_advertise_attr));
+ return XCALLOC(MTYPE_BGP_ADVERTISE_ATTR,
+ sizeof(struct bgp_advertise_attr));
}
static void baa_free(struct bgp_advertise_attr *baa)
@@ -84,8 +84,7 @@ bool baa_hash_cmp(const void *p1, const void *p2)
information. */
struct bgp_advertise *bgp_advertise_new(void)
{
- return (struct bgp_advertise *)XCALLOC(MTYPE_BGP_ADVERTISE,
- sizeof(struct bgp_advertise));
+ return XCALLOC(MTYPE_BGP_ADVERTISE, sizeof(struct bgp_advertise));
}
void bgp_advertise_free(struct bgp_advertise *adv)
@@ -255,8 +254,7 @@ void bgp_sync_delete(struct peer *peer)
safi_t safi;
FOREACH_AFI_SAFI (afi, safi) {
- if (peer->sync[afi][safi])
- XFREE(MTYPE_BGP_SYNCHRONISE, peer->sync[afi][safi]);
+ XFREE(MTYPE_BGP_SYNCHRONISE, peer->sync[afi][safi]);
peer->sync[afi][safi] = NULL;
}
}
diff --git a/bgpd/bgp_aspath.c b/bgpd/bgp_aspath.c
index 3bd3de031..92c37fabd 100644
--- a/bgpd/bgp_aspath.c
+++ b/bgpd/bgp_aspath.c
@@ -312,8 +312,7 @@ void aspath_free(struct aspath *aspath)
return;
if (aspath->segments)
assegment_free_all(aspath->segments);
- if (aspath->str)
- XFREE(MTYPE_AS_STR, aspath->str);
+ XFREE(MTYPE_AS_STR, aspath->str);
if (aspath->json) {
json_object_free(aspath->json);
@@ -623,8 +622,7 @@ static void aspath_make_str_count(struct aspath *as, bool make_json)
void aspath_str_update(struct aspath *as, bool make_json)
{
- if (as->str)
- XFREE(MTYPE_AS_STR, as->str);
+ XFREE(MTYPE_AS_STR, as->str);
if (as->json) {
json_object_free(as->json);
diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c
index 4c6da724b..226bf99d2 100644
--- a/bgpd/bgp_attr.c
+++ b/bgpd/bgp_attr.c
@@ -159,8 +159,7 @@ static bool cluster_hash_cmp(const void *p1, const void *p2)
static void cluster_free(struct cluster_list *cluster)
{
- if (cluster->list)
- XFREE(MTYPE_CLUSTER_VAL, cluster->list);
+ XFREE(MTYPE_CLUSTER_VAL, cluster->list);
XFREE(MTYPE_CLUSTER, cluster);
}
@@ -401,8 +400,7 @@ static struct hash *transit_hash;
static void transit_free(struct transit *transit)
{
- if (transit->val)
- XFREE(MTYPE_TRANSIT_VAL, transit->val);
+ XFREE(MTYPE_TRANSIT_VAL, transit->val);
XFREE(MTYPE_TRANSIT, transit);
}
diff --git a/bgpd/bgp_attr_evpn.c b/bgpd/bgp_attr_evpn.c
index 208a9d470..15fa32215 100644
--- a/bgpd/bgp_attr_evpn.c
+++ b/bgpd/bgp_attr_evpn.c
@@ -84,8 +84,8 @@ char *esi2str(struct eth_segment_id *id)
return NULL;
val = id->val;
- ptr = (char *)XMALLOC(MTYPE_TMP,
- (ESI_LEN * 2 + ESI_LEN - 1 + 1) * sizeof(char));
+ ptr = XMALLOC(MTYPE_TMP,
+ (ESI_LEN * 2 + ESI_LEN - 1 + 1) * sizeof(char));
snprintf(ptr, (ESI_LEN * 2 + ESI_LEN - 1 + 1),
"%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", val[0],
diff --git a/bgpd/bgp_clist.c b/bgpd/bgp_clist.c
index 84a00488c..7b64f349d 100644
--- a/bgpd/bgp_clist.c
+++ b/bgpd/bgp_clist.c
@@ -100,16 +100,14 @@ static void community_entry_free(struct community_entry *entry)
case EXTCOMMUNITY_LIST_STANDARD:
/* In case of standard extcommunity-list, configuration string
is made by ecommunity_ecom2str(). */
- if (entry->config)
- XFREE(MTYPE_ECOMMUNITY_STR, entry->config);
+ XFREE(MTYPE_ECOMMUNITY_STR, entry->config);
if (entry->u.ecom)
ecommunity_free(&entry->u.ecom);
break;
case COMMUNITY_LIST_EXPANDED:
case EXTCOMMUNITY_LIST_EXPANDED:
case LARGE_COMMUNITY_LIST_EXPANDED:
- if (entry->config)
- XFREE(MTYPE_COMMUNITY_LIST_CONFIG, entry->config);
+ XFREE(MTYPE_COMMUNITY_LIST_CONFIG, entry->config);
if (entry->reg)
bgp_regex_free(entry->reg);
default:
@@ -127,8 +125,7 @@ static struct community_list *community_list_new(void)
/* Free community-list. */
static void community_list_free(struct community_list *list)
{
- if (list->name)
- XFREE(MTYPE_COMMUNITY_LIST_NAME, list->name);
+ XFREE(MTYPE_COMMUNITY_LIST_NAME, list->name);
XFREE(MTYPE_COMMUNITY_LIST, list);
}
diff --git a/bgpd/bgp_community.c b/bgpd/bgp_community.c
index 2e28c3095..67cd2be21 100644
--- a/bgpd/bgp_community.c
+++ b/bgpd/bgp_community.c
@@ -34,17 +34,14 @@ static struct hash *comhash;
/* Allocate a new communities value. */
static struct community *community_new(void)
{
- return (struct community *)XCALLOC(MTYPE_COMMUNITY,
- sizeof(struct community));
+ return XCALLOC(MTYPE_COMMUNITY, sizeof(struct community));
}
/* Free communities value. */
void community_free(struct community **com)
{
- if ((*com)->val)
- XFREE(MTYPE_COMMUNITY_VAL, (*com)->val);
- if ((*com)->str)
- XFREE(MTYPE_COMMUNITY_STR, (*com)->str);
+ XFREE(MTYPE_COMMUNITY_VAL, (*com)->val);
+ XFREE(MTYPE_COMMUNITY_STR, (*com)->str);
if ((*com)->json) {
json_object_free((*com)->json);
diff --git a/bgpd/bgp_ecommunity.c b/bgpd/bgp_ecommunity.c
index fcfaa388d..8ef398952 100644
--- a/bgpd/bgp_ecommunity.c
+++ b/bgpd/bgp_ecommunity.c
@@ -48,8 +48,7 @@ static struct hash *ecomhash;
/* Allocate a new ecommunities. */
struct ecommunity *ecommunity_new(void)
{
- return (struct ecommunity *)XCALLOC(MTYPE_ECOMMUNITY,
- sizeof(struct ecommunity));
+ return XCALLOC(MTYPE_ECOMMUNITY, sizeof(struct ecommunity));
}
void ecommunity_strfree(char **s)
@@ -60,10 +59,8 @@ void ecommunity_strfree(char **s)
/* Allocate ecommunities. */
void ecommunity_free(struct ecommunity **ecom)
{
- if ((*ecom)->val)
- XFREE(MTYPE_ECOMMUNITY_VAL, (*ecom)->val);
- if ((*ecom)->str)
- XFREE(MTYPE_ECOMMUNITY_STR, (*ecom)->str);
+ XFREE(MTYPE_ECOMMUNITY_VAL, (*ecom)->val);
+ XFREE(MTYPE_ECOMMUNITY_STR, (*ecom)->str);
XFREE(MTYPE_ECOMMUNITY, *ecom);
}
diff --git a/bgpd/bgp_encap_tlv.c b/bgpd/bgp_encap_tlv.c
index 30a08098e..964adec9b 100644
--- a/bgpd/bgp_encap_tlv.c
+++ b/bgpd/bgp_encap_tlv.c
@@ -401,8 +401,7 @@ void bgp_encap_type_vxlan_to_tlv(
if (bet == NULL || !bet->vnid)
return;
- if (attr->encap_subtlvs)
- XFREE(MTYPE_ENCAP_TLV, attr->encap_subtlvs);
+ XFREE(MTYPE_ENCAP_TLV, attr->encap_subtlvs);
tlv = XCALLOC(MTYPE_ENCAP_TLV,
sizeof(struct bgp_attr_encap_subtlv) + 12);
tlv->type = 1; /* encapsulation type */
diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c
index f123b7f8e..84f364975 100644
--- a/bgpd/bgp_evpn.c
+++ b/bgpd/bgp_evpn.c
@@ -184,8 +184,6 @@ static struct vrf_irt_node *vrf_import_rt_new(struct ecommunity_val *rt)
irt = XCALLOC(MTYPE_BGP_EVPN_VRF_IMPORT_RT,
sizeof(struct vrf_irt_node));
- if (!irt)
- return NULL;
irt->rt = *rt;
irt->vrfs = list_new();
@@ -296,8 +294,6 @@ static struct irt_node *import_rt_new(struct bgp *bgp,
return NULL;
irt = XCALLOC(MTYPE_BGP_EVPN_IMPORT_RT, sizeof(struct irt_node));
- if (!irt)
- return NULL;
irt->rt = *rt;
irt->vnis = list_new();
@@ -968,8 +964,6 @@ static struct in_addr *es_vtep_new(struct in_addr vtep)
struct in_addr *ip;
ip = XCALLOC(MTYPE_BGP_EVPN_ES_VTEP, sizeof(struct in_addr));
- if (!ip)
- return NULL;
ip->s_addr = vtep.s_addr;
return ip;
@@ -5100,8 +5094,6 @@ struct bgpevpn *bgp_evpn_new(struct bgp *bgp, vni_t vni,
return NULL;
vpn = XCALLOC(MTYPE_BGP_EVPN, sizeof(struct bgpevpn));
- if (!vpn)
- return NULL;
/* Set values - RD and RT set to defaults. */
vpn->vni = vni;
@@ -5181,8 +5173,6 @@ struct evpnes *bgp_evpn_es_new(struct bgp *bgp,
return NULL;
es = XCALLOC(MTYPE_BGP_EVPN_ES, sizeof(struct evpnes));
- if (!es)
- return NULL;
/* set the ESI and originator_ip */
memcpy(&es->esi, esi, sizeof(esi_t));
diff --git a/bgpd/bgp_filter.c b/bgpd/bgp_filter.c
index 1ccb8fb24..80cfb9743 100644
--- a/bgpd/bgp_filter.c
+++ b/bgpd/bgp_filter.c
@@ -95,8 +95,7 @@ static void as_filter_free(struct as_filter *asfilter)
{
if (asfilter->reg)
bgp_regex_free(asfilter->reg);
- if (asfilter->reg_str)
- XFREE(MTYPE_AS_FILTER_STR, asfilter->reg_str);
+ XFREE(MTYPE_AS_FILTER_STR, asfilter->reg_str);
XFREE(MTYPE_AS_FILTER, asfilter);
}
@@ -338,8 +337,7 @@ static void as_list_filter_delete(struct as_list *aslist,
/* Run hook function. */
if (as_list_master.delete_hook)
(*as_list_master.delete_hook)(name);
- if (name)
- XFREE(MTYPE_AS_STR, name);
+ XFREE(MTYPE_AS_STR, name);
}
static int as_filter_match(struct as_filter *asfilter, struct aspath *aspath)
diff --git a/bgpd/bgp_labelpool.c b/bgpd/bgp_labelpool.c
index 181f86457..69dd0f9da 100644
--- a/bgpd/bgp_labelpool.c
+++ b/bgpd/bgp_labelpool.c
@@ -180,14 +180,12 @@ static void lp_cbq_item_free(struct work_queue *wq, void *data)
static void lp_lcb_free(void *goner)
{
- if (goner)
- XFREE(MTYPE_BGP_LABEL_CB, goner);
+ XFREE(MTYPE_BGP_LABEL_CB, goner);
}
static void lp_chunk_free(void *goner)
{
- if (goner)
- XFREE(MTYPE_BGP_LABEL_CHUNK, goner);
+ XFREE(MTYPE_BGP_LABEL_CHUNK, goner);
}
void bgp_lp_init(struct thread_master *master, struct labelpool *pool)
diff --git a/bgpd/bgp_lcommunity.c b/bgpd/bgp_lcommunity.c
index 1e4589719..44766c9b6 100644
--- a/bgpd/bgp_lcommunity.c
+++ b/bgpd/bgp_lcommunity.c
@@ -38,17 +38,14 @@ static struct hash *lcomhash;
/* Allocate a new lcommunities. */
static struct lcommunity *lcommunity_new(void)
{
- return (struct lcommunity *)XCALLOC(MTYPE_LCOMMUNITY,
- sizeof(struct lcommunity));
+ return XCALLOC(MTYPE_LCOMMUNITY, sizeof(struct lcommunity));
}
/* Allocate lcommunities. */
void lcommunity_free(struct lcommunity **lcom)
{
- if ((*lcom)->val)
- XFREE(MTYPE_LCOMMUNITY_VAL, (*lcom)->val);
- if ((*lcom)->str)
- XFREE(MTYPE_LCOMMUNITY_STR, (*lcom)->str);
+ XFREE(MTYPE_LCOMMUNITY_VAL, (*lcom)->val);
+ XFREE(MTYPE_LCOMMUNITY_STR, (*lcom)->str);
XFREE(MTYPE_LCOMMUNITY, *lcom);
}
@@ -180,7 +177,7 @@ static void set_lcommunity_string(struct lcommunity *lcom, bool make_json)
{
int i;
int len;
- bool first = 1;
+ bool first = true;
char *str_buf;
char *str_pnt;
uint8_t *pnt;
@@ -218,7 +215,7 @@ static void set_lcommunity_string(struct lcommunity *lcom, bool make_json)
for (i = 0; i < lcom->size; i++) {
if (first)
- first = 0;
+ first = false;
else
*str_pnt++ = ' ';
@@ -319,10 +316,10 @@ bool lcommunity_cmp(const void *arg1, const void *arg2)
const struct lcommunity *lcom2 = arg2;
if (lcom1 == NULL && lcom2 == NULL)
- return 1;
+ return true;
if (lcom1 == NULL || lcom2 == NULL)
- return 0;
+ return false;
return (lcom1->size == lcom2->size
&& memcmp(lcom1->val, lcom2->val, lcom_length(lcom1)) == 0);
diff --git a/bgpd/bgp_mpath.c b/bgpd/bgp_mpath.c
index 241146e45..d5b3d6b19 100644
--- a/bgpd/bgp_mpath.c
+++ b/bgpd/bgp_mpath.c
@@ -671,7 +671,7 @@ void bgp_mp_dmed_deselect(struct bgp_path_info *dmed_best)
bgp_path_info_mpath_count_set(dmed_best, 0);
UNSET_FLAG(dmed_best->flags, BGP_PATH_MULTIPATH_CHG);
- assert(bgp_path_info_mpath_first(dmed_best) == 0);
+ assert(bgp_path_info_mpath_first(dmed_best) == NULL);
}
/*
diff --git a/bgpd/bgp_pbr.c b/bgpd/bgp_pbr.c
index 4c51db8e1..c0be36ed3 100644
--- a/bgpd/bgp_pbr.c
+++ b/bgpd/bgp_pbr.c
@@ -333,7 +333,7 @@ static bool bgp_pbr_extract_enumerate_unary(struct bgp_pbr_match_val list[],
unary_operator, and_valmask,
or_valmask, list[i].value,
type_entry);
- if (ret == false)
+ if (!ret)
return ret;
continue;
}
@@ -441,7 +441,7 @@ static bool bgp_pbr_extract(struct bgp_pbr_match_val list[],
range->min_port = list[i].value;
exact_match = true;
}
- if (exact_match == true && i > 0)
+ if (exact_match && i > 0)
return false;
if (list[i].compare_operator ==
(OPERATOR_COMPARE_GREATER_THAN +
@@ -545,7 +545,7 @@ static int bgp_pbr_validate_policy_route(struct bgp_pbr_entry_main *api)
"too complex. ignoring.");
return 0;
} else if (api->match_icmp_type_num > 1 &&
- enumerate_icmp == false) {
+ !enumerate_icmp) {
if (BGP_DEBUG(pbr, PBR))
zlog_debug("BGP: match icmp code is enumerate"
", and icmp type is not."
diff --git a/bgpd/bgp_rd.c b/bgpd/bgp_rd.c
index 77f5aade5..571139a49 100644
--- a/bgpd/bgp_rd.c
+++ b/bgpd/bgp_rd.c
@@ -155,8 +155,7 @@ int str2prefix_rd(const char *str, struct prefix_rd *prd)
out:
if (s)
stream_free(s);
- if (half)
- XFREE(MTYPE_TMP, half);
+ XFREE(MTYPE_TMP, half);
return lret;
}
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index a83e4419e..90a8f8cec 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -4468,12 +4468,10 @@ static struct bgp_static *bgp_static_new(void)
static void bgp_static_free(struct bgp_static *bgp_static)
{
- if (bgp_static->rmap.name)
- XFREE(MTYPE_ROUTE_MAP_NAME, bgp_static->rmap.name);
+ XFREE(MTYPE_ROUTE_MAP_NAME, bgp_static->rmap.name);
route_map_counter_decrement(bgp_static->rmap.map);
- if (bgp_static->eth_s_id)
- XFREE(MTYPE_ATTR, bgp_static->eth_s_id);
+ XFREE(MTYPE_ATTR, bgp_static->eth_s_id);
XFREE(MTYPE_BGP_STATIC, bgp_static);
}
@@ -5033,9 +5031,8 @@ static int bgp_static_set(struct vty *vty, const char *negate,
bgp_static->backdoor = backdoor;
if (rmap) {
- if (bgp_static->rmap.name)
- XFREE(MTYPE_ROUTE_MAP_NAME,
- bgp_static->rmap.name);
+ XFREE(MTYPE_ROUTE_MAP_NAME,
+ bgp_static->rmap.name);
route_map_counter_decrement(
bgp_static->rmap.map);
bgp_static->rmap.name =
@@ -5045,9 +5042,8 @@ static int bgp_static_set(struct vty *vty, const char *negate,
route_map_counter_increment(
bgp_static->rmap.map);
} else {
- if (bgp_static->rmap.name)
- XFREE(MTYPE_ROUTE_MAP_NAME,
- bgp_static->rmap.name);
+ XFREE(MTYPE_ROUTE_MAP_NAME,
+ bgp_static->rmap.name);
route_map_counter_decrement(
bgp_static->rmap.map);
bgp_static->rmap.name = NULL;
@@ -5065,9 +5061,8 @@ static int bgp_static_set(struct vty *vty, const char *negate,
bgp_static->label_index = label_index;
if (rmap) {
- if (bgp_static->rmap.name)
- XFREE(MTYPE_ROUTE_MAP_NAME,
- bgp_static->rmap.name);
+ XFREE(MTYPE_ROUTE_MAP_NAME,
+ bgp_static->rmap.name);
route_map_counter_decrement(
bgp_static->rmap.map);
bgp_static->rmap.name =
@@ -5351,9 +5346,7 @@ int bgp_static_set_safi(afi_t afi, safi_t safi, struct vty *vty,
bgp_static->prd = prd;
if (rmap_str) {
- if (bgp_static->rmap.name)
- XFREE(MTYPE_ROUTE_MAP_NAME,
- bgp_static->rmap.name);
+ XFREE(MTYPE_ROUTE_MAP_NAME, bgp_static->rmap.name);
route_map_counter_decrement(bgp_static->rmap.map);
bgp_static->rmap.name =
XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str);
@@ -5460,15 +5453,13 @@ static int bgp_table_map_set(struct vty *vty, afi_t afi, safi_t safi,
rmap = &bgp->table_map[afi][safi];
if (rmap_name) {
- if (rmap->name)
- XFREE(MTYPE_ROUTE_MAP_NAME, rmap->name);
+ XFREE(MTYPE_ROUTE_MAP_NAME, rmap->name);
route_map_counter_decrement(rmap->map);
rmap->name = XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_name);
rmap->map = route_map_lookup_by_name(rmap_name);
route_map_counter_increment(rmap->map);
} else {
- if (rmap->name)
- XFREE(MTYPE_ROUTE_MAP_NAME, rmap->name);
+ XFREE(MTYPE_ROUTE_MAP_NAME, rmap->name);
route_map_counter_decrement(rmap->map);
rmap->name = NULL;
rmap->map = NULL;
@@ -5487,8 +5478,7 @@ static int bgp_table_map_unset(struct vty *vty, afi_t afi, safi_t safi,
struct bgp_rmap *rmap;
rmap = &bgp->table_map[afi][safi];
- if (rmap->name)
- XFREE(MTYPE_ROUTE_MAP_NAME, rmap->name);
+ XFREE(MTYPE_ROUTE_MAP_NAME, rmap->name);
route_map_counter_decrement(rmap->map);
rmap->name = NULL;
rmap->map = NULL;
@@ -11461,8 +11451,7 @@ static int bgp_distance_unset(struct vty *vty, const char *distance_str,
return CMD_WARNING_CONFIG_FAILED;
}
- if (bdistance->access_list)
- XFREE(MTYPE_AS_LIST, bdistance->access_list);
+ XFREE(MTYPE_AS_LIST, bdistance->access_list);
bgp_distance_free(bdistance);
bgp_node_set_bgp_path_info(rn, NULL);
@@ -12049,10 +12038,8 @@ static void bgp_config_write_network_evpn(struct vty *vty, struct bgp *bgp,
decode_label(&bgp_static->label), esi, buf2,
macrouter);
- if (macrouter)
- XFREE(MTYPE_TMP, macrouter);
- if (esi)
- XFREE(MTYPE_TMP, esi);
+ XFREE(MTYPE_TMP, macrouter);
+ XFREE(MTYPE_TMP, esi);
}
}
}
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c
index 17109281b..626643a15 100644
--- a/bgpd/bgp_routemap.c
+++ b/bgpd/bgp_routemap.c
@@ -197,8 +197,6 @@ static void *route_value_compile(const char *arg)
}
rv = XMALLOC(MTYPE_ROUTE_MAP_COMPILED, sizeof(struct rmap_value));
- if (!rv)
- return NULL;
rv->action = action;
rv->variable = var;
@@ -324,8 +322,7 @@ static void route_match_peer_free(void *rule)
{
struct bgp_match_peer_compiled *pc = rule;
- if (pc->interface)
- XFREE(MTYPE_ROUTE_MAP_COMPILED, pc->interface);
+ XFREE(MTYPE_ROUTE_MAP_COMPILED, pc->interface);
XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
}
@@ -837,8 +834,6 @@ static void *route_match_vni_compile(const char *arg)
char *end = NULL;
vni = XMALLOC(MTYPE_ROUTE_MAP_COMPILED, sizeof(vni_t));
- if (!vni)
- return NULL;
*vni = strtoul(arg, &end, 10);
if (*end != '\0') {
@@ -998,9 +993,6 @@ static void *route_match_local_pref_compile(const char *arg)
local_pref = XMALLOC(MTYPE_ROUTE_MAP_COMPILED, sizeof(uint32_t));
- if (!local_pref)
- return local_pref;
-
*local_pref = tmpval;
return local_pref;
}
@@ -1555,8 +1547,7 @@ static void route_set_ip_nexthop_free(void *rule)
{
struct rmap_ip_nexthop_set *rins = rule;
- if (rins->address)
- XFREE(MTYPE_ROUTE_MAP_COMPILED, rins->address);
+ XFREE(MTYPE_ROUTE_MAP_COMPILED, rins->address);
XFREE(MTYPE_ROUTE_MAP_COMPILED, rins);
}
@@ -3105,10 +3096,8 @@ static int bgp_route_match_delete(struct vty *vty, const char *command,
break;
}
- if (dep_name)
- XFREE(MTYPE_ROUTE_MAP_RULE, dep_name);
- if (rmap_name)
- XFREE(MTYPE_ROUTE_MAP_NAME, rmap_name);
+ XFREE(MTYPE_ROUTE_MAP_RULE, dep_name);
+ XFREE(MTYPE_ROUTE_MAP_NAME, rmap_name);
return retval;
}
diff --git a/bgpd/bgp_snmp.c b/bgpd/bgp_snmp.c
index c1321dd7d..44cbeabd6 100644
--- a/bgpd/bgp_snmp.c
+++ b/bgpd/bgp_snmp.c
@@ -900,11 +900,10 @@ static int bgpTrapEstablished(struct peer *peer)
oid_copy_addr(index, &addr, IN_ADDR_SIZE);
- smux_trap(bgp_variables, sizeof bgp_variables / sizeof(struct variable),
- bgp_trap_oid, sizeof bgp_trap_oid / sizeof(oid), bgp_oid,
+ smux_trap(bgp_variables, array_size(bgp_variables), bgp_trap_oid,
+ array_size(bgp_trap_oid), bgp_oid,
sizeof bgp_oid / sizeof(oid), index, IN_ADDR_SIZE,
- bgpTrapList, sizeof bgpTrapList / sizeof(struct trap_object),
- BGPESTABLISHED);
+ bgpTrapList, array_size(bgpTrapList), BGPESTABLISHED);
return 0;
}
@@ -920,11 +919,10 @@ static int bgpTrapBackwardTransition(struct peer *peer)
oid_copy_addr(index, &addr, IN_ADDR_SIZE);
- smux_trap(bgp_variables, sizeof bgp_variables / sizeof(struct variable),
- bgp_trap_oid, sizeof bgp_trap_oid / sizeof(oid), bgp_oid,
+ smux_trap(bgp_variables, array_size(bgp_variables), bgp_trap_oid,
+ array_size(bgp_trap_oid), bgp_oid,
sizeof bgp_oid / sizeof(oid), index, IN_ADDR_SIZE,
- bgpTrapList, sizeof bgpTrapList / sizeof(struct trap_object),
- BGPBACKWARDTRANSITION);
+ bgpTrapList, array_size(bgpTrapList), BGPBACKWARDTRANSITION);
return 0;
}
diff --git a/bgpd/bgp_updgrp.c b/bgpd/bgp_updgrp.c
index b74dc33ea..49a435120 100644
--- a/bgpd/bgp_updgrp.c
+++ b/bgpd/bgp_updgrp.c
@@ -110,8 +110,7 @@ static void sync_init(struct update_subgroup *subgrp)
static void sync_delete(struct update_subgroup *subgrp)
{
- if (subgrp->sync)
- XFREE(MTYPE_BGP_SYNCHRONISE, subgrp->sync);
+ XFREE(MTYPE_BGP_SYNCHRONISE, subgrp->sync);
subgrp->sync = NULL;
if (subgrp->hash)
hash_free(subgrp->hash);
@@ -144,8 +143,7 @@ static void conf_copy(struct peer *dst, struct peer *src, afi_t afi,
dst->v_routeadv = src->v_routeadv;
dst->flags = src->flags;
dst->af_flags[afi][safi] = src->af_flags[afi][safi];
- if (dst->host)
- XFREE(MTYPE_BGP_PEER_HOST, dst->host);
+ XFREE(MTYPE_BGP_PEER_HOST, dst->host);
dst->host = XSTRDUP(MTYPE_BGP_PEER_HOST, src->host);
dst->cap = src->cap;
@@ -208,27 +206,19 @@ static void conf_release(struct peer *src, afi_t afi, safi_t safi)
srcfilter = &src->filter[afi][safi];
- if (src->default_rmap[afi][safi].name)
- XFREE(MTYPE_ROUTE_MAP_NAME, src->default_rmap[afi][safi].name);
+ XFREE(MTYPE_ROUTE_MAP_NAME, src->default_rmap[afi][safi].name);
- if (srcfilter->dlist[FILTER_OUT].name)
- XFREE(MTYPE_BGP_FILTER_NAME, srcfilter->dlist[FILTER_OUT].name);
+ XFREE(MTYPE_BGP_FILTER_NAME, srcfilter->dlist[FILTER_OUT].name);
- if (srcfilter->plist[FILTER_OUT].name)
- XFREE(MTYPE_BGP_FILTER_NAME, srcfilter->plist[FILTER_OUT].name);
+ XFREE(MTYPE_BGP_FILTER_NAME, srcfilter->plist[FILTER_OUT].name);
- if (srcfilter->aslist[FILTER_OUT].name)
- XFREE(MTYPE_BGP_FILTER_NAME,
- srcfilter->aslist[FILTER_OUT].name);
+ XFREE(MTYPE_BGP_FILTER_NAME, srcfilter->aslist[FILTER_OUT].name);
- if (srcfilter->map[RMAP_OUT].name)
- XFREE(MTYPE_BGP_FILTER_NAME, srcfilter->map[RMAP_OUT].name);
+ XFREE(MTYPE_BGP_FILTER_NAME, srcfilter->map[RMAP_OUT].name);
- if (srcfilter->usmap.name)
- XFREE(MTYPE_BGP_FILTER_NAME, srcfilter->usmap.name);
+ XFREE(MTYPE_BGP_FILTER_NAME, srcfilter->usmap.name);
- if (src->host)
- XFREE(MTYPE_BGP_PEER_HOST, src->host);
+ XFREE(MTYPE_BGP_PEER_HOST, src->host);
src->host = NULL;
}
@@ -440,7 +430,7 @@ static bool updgrp_hash_cmp(const void *p1, const void *p2)
return false;
if (pe1->addpath_type[afi][safi] != pe2->addpath_type[afi][safi])
- return 0;
+ return false;
if ((pe1->cap & PEER_UPDGRP_CAP_FLAGS)
!= (pe2->cap & PEER_UPDGRP_CAP_FLAGS))
@@ -741,12 +731,10 @@ static void update_group_delete(struct update_group *updgrp)
hash_release(updgrp->bgp->update_groups[updgrp->afid], updgrp);
conf_release(updgrp->conf, updgrp->afi, updgrp->safi);
- if (updgrp->conf->host)
- XFREE(MTYPE_BGP_PEER_HOST, updgrp->conf->host);
+ XFREE(MTYPE_BGP_PEER_HOST, updgrp->conf->host);
updgrp->conf->host = NULL;
- if (updgrp->conf->ifname)
- XFREE(MTYPE_BGP_PEER_IFNAME, updgrp->conf->ifname);
+ XFREE(MTYPE_BGP_PEER_IFNAME, updgrp->conf->ifname);
XFREE(MTYPE_BGP_PEER, updgrp->conf);
XFREE(MTYPE_BGP_UPDGRP, updgrp);
diff --git a/bgpd/bgp_updgrp_packet.c b/bgpd/bgp_updgrp_packet.c
index cbbf8b230..66e306cba 100644
--- a/bgpd/bgp_updgrp_packet.c
+++ b/bgpd/bgp_updgrp_packet.c
@@ -69,8 +69,7 @@ struct bpacket *bpacket_alloc(void)
{
struct bpacket *pkt;
- pkt = (struct bpacket *)XCALLOC(MTYPE_BGP_PACKET,
- sizeof(struct bpacket));
+ pkt = XCALLOC(MTYPE_BGP_PACKET, sizeof(struct bpacket));
return pkt;
}
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index 93d22087b..d426e65c5 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -14456,8 +14456,7 @@ static int lcommunity_list_set_vty(struct vty *vty, int argc,
/* Free temporary community list string allocated by
argv_concat(). */
- if (str)
- XFREE(MTYPE_TMP, str);
+ XFREE(MTYPE_TMP, str);
if (ret < 0) {
community_list_perror(vty, ret);
@@ -14508,8 +14507,7 @@ static int lcommunity_list_unset_vty(struct vty *vty, int argc,
/* Free temporary community list string allocated by
argv_concat(). */
- if (str)
- XFREE(MTYPE_TMP, str);
+ XFREE(MTYPE_TMP, str);
if (ret < 0) {
community_list_perror(vty, ret);
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index f833ab89d..5f0b20e02 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -1586,8 +1586,7 @@ struct bgp_redist *bgp_redist_add(struct bgp *bgp, afi_t afi, uint8_t type,
bgp->redist[afi][type] = list_new();
red_list = bgp->redist[afi][type];
- red = (struct bgp_redist *)XCALLOC(MTYPE_BGP_REDIST,
- sizeof(struct bgp_redist));
+ red = XCALLOC(MTYPE_BGP_REDIST, sizeof(struct bgp_redist));
red->instance = instance;
listnode_add(red_list, red);
@@ -1694,8 +1693,7 @@ int bgp_redistribute_rmap_set(struct bgp_redist *red, const char *name,
if (red->rmap.name && (strcmp(red->rmap.name, name) == 0))
return 0;
- if (red->rmap.name)
- XFREE(MTYPE_ROUTE_MAP_NAME, red->rmap.name);
+ XFREE(MTYPE_ROUTE_MAP_NAME, red->rmap.name);
/* Decrement the count for existing routemap and
* increment the count for new route map.
*/
@@ -1808,8 +1806,7 @@ int bgp_redistribute_unset(struct bgp *bgp, afi_t afi, int type,
bgp_redistribute_unreg(bgp, afi, type, instance);
/* Unset route-map. */
- if (red->rmap.name)
- XFREE(MTYPE_ROUTE_MAP_NAME, red->rmap.name);
+ XFREE(MTYPE_ROUTE_MAP_NAME, red->rmap.name);
route_map_counter_decrement(red->rmap.map);
red->rmap.name = NULL;
red->rmap.map = NULL;
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index a920cfeee..d99b402e2 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -116,7 +116,7 @@ static int bgp_check_main_socket(bool create, struct bgp *bgp)
{
static int bgp_server_main_created;
- if (create == true) {
+ if (create) {
if (bgp_server_main_created)
return 0;
if (bgp_socket(bgp, bm->port, bm->address) < 0)
@@ -1099,8 +1099,7 @@ static void peer_free(struct peer *peer)
peer->update_if = NULL;
}
- if (peer->notify.data)
- XFREE(MTYPE_TMP, peer->notify.data);
+ XFREE(MTYPE_TMP, peer->notify.data);
memset(&peer->notify, 0, sizeof(struct bgp_notify));
if (peer->clear_node_queue)
@@ -1322,8 +1321,7 @@ void peer_xfer_config(struct peer *peer_dst, struct peer *peer_src)
peer_dst->update_source =
sockunion_dup(peer_src->update_source);
} else if (peer_src->update_if) {
- if (peer_dst->update_if)
- XFREE(MTYPE_PEER_UPDATE_SOURCE, peer_dst->update_if);
+ XFREE(MTYPE_PEER_UPDATE_SOURCE, peer_dst->update_if);
if (peer_dst->update_source) {
sockunion_free(peer_dst->update_source);
peer_dst->update_source = NULL;
@@ -1333,8 +1331,7 @@ void peer_xfer_config(struct peer *peer_dst, struct peer *peer_src)
}
if (peer_src->ifname) {
- if (peer_dst->ifname)
- XFREE(MTYPE_BGP_PEER_IFNAME, peer_dst->ifname);
+ XFREE(MTYPE_BGP_PEER_IFNAME, peer_dst->ifname);
peer_dst->ifname =
XSTRDUP(MTYPE_BGP_PEER_IFNAME, peer_src->ifname);
@@ -1541,14 +1538,12 @@ struct peer *peer_create(union sockunion *su, const char *conf_if,
peer->su = *su;
else
bgp_peer_conf_if_to_su_update(peer);
- if (peer->host)
- XFREE(MTYPE_BGP_PEER_HOST, peer->host);
+ XFREE(MTYPE_BGP_PEER_HOST, peer->host);
peer->host = XSTRDUP(MTYPE_BGP_PEER_HOST, conf_if);
} else if (su) {
peer->su = *su;
sockunion2str(su, buf, SU_ADDRSTRLEN);
- if (peer->host)
- XFREE(MTYPE_BGP_PEER_HOST, peer->host);
+ XFREE(MTYPE_BGP_PEER_HOST, peer->host);
peer->host = XSTRDUP(MTYPE_BGP_PEER_HOST, buf);
}
peer->local_as = local_as;
@@ -2384,8 +2379,7 @@ static int peer_group_cmp(struct peer_group *g1, struct peer_group *g2)
/* Peer group cofiguration. */
static struct peer_group *peer_group_new(void)
{
- return (struct peer_group *)XCALLOC(MTYPE_PEER_GROUP,
- sizeof(struct peer_group));
+ return XCALLOC(MTYPE_PEER_GROUP, sizeof(struct peer_group));
}
static void peer_group_free(struct peer_group *group)
@@ -2416,8 +2410,7 @@ struct peer_group *peer_group_get(struct bgp *bgp, const char *name)
group = peer_group_new();
group->bgp = bgp;
- if (group->name)
- XFREE(MTYPE_PEER_GROUP_HOST, group->name);
+ XFREE(MTYPE_PEER_GROUP_HOST, group->name);
group->name = XSTRDUP(MTYPE_PEER_GROUP_HOST, name);
group->peer = list_new();
for (afi = AFI_IP; afi < AFI_MAX; afi++)
@@ -2425,8 +2418,7 @@ struct peer_group *peer_group_get(struct bgp *bgp, const char *name)
group->conf = peer_new(bgp);
if (!bgp_flag_check(bgp, BGP_FLAG_NO_DEFAULT_IPV4))
group->conf->afc[AFI_IP][SAFI_UNICAST] = 1;
- if (group->conf->host)
- XFREE(MTYPE_BGP_PEER_HOST, group->conf->host);
+ XFREE(MTYPE_BGP_PEER_HOST, group->conf->host);
group->conf->host = XSTRDUP(MTYPE_BGP_PEER_HOST, name);
group->conf->group = group;
group->conf->as = 0;
@@ -2886,8 +2878,7 @@ static struct bgp *bgp_create(as_t *as, const char *name,
bgp->vrf_id = (inst_type == BGP_INSTANCE_TYPE_DEFAULT) ? VRF_DEFAULT
: VRF_UNKNOWN;
bgp->peer_self = peer_new(bgp);
- if (bgp->peer_self->host)
- XFREE(MTYPE_BGP_PEER_HOST, bgp->peer_self->host);
+ XFREE(MTYPE_BGP_PEER_HOST, bgp->peer_self->host);
bgp->peer_self->host =
XSTRDUP(MTYPE_BGP_PEER_HOST, "Static announcement");
if (bgp->peer_self->hostname != NULL) {
@@ -3404,8 +3395,7 @@ void bgp_free(struct bgp *bgp)
if (bgp->rib[afi][safi])
bgp_table_finish(&bgp->rib[afi][safi]);
rmap = &bgp->table_map[afi][safi];
- if (rmap->name)
- XFREE(MTYPE_ROUTE_MAP_NAME, rmap->name);
+ XFREE(MTYPE_ROUTE_MAP_NAME, rmap->name);
}
bgp_scan_finish(bgp);
@@ -3435,10 +3425,8 @@ void bgp_free(struct bgp *bgp)
ecommunity_free(&bgp->vpn_policy[afi].rtlist[dir]);
}
- if (bgp->name)
- XFREE(MTYPE_BGP, bgp->name);
- if (bgp->name_pretty)
- XFREE(MTYPE_BGP, bgp->name_pretty);
+ XFREE(MTYPE_BGP, bgp->name);
+ XFREE(MTYPE_BGP, bgp->name_pretty);
XFREE(MTYPE_BGP, bgp);
}
@@ -4368,8 +4356,7 @@ int peer_ebgp_multihop_unset(struct peer *peer)
/* Neighbor description. */
int peer_description_set(struct peer *peer, const char *desc)
{
- if (peer->desc)
- XFREE(MTYPE_PEER_DESC, peer->desc);
+ XFREE(MTYPE_PEER_DESC, peer->desc);
peer->desc = XSTRDUP(MTYPE_PEER_DESC, desc);
@@ -4378,8 +4365,7 @@ int peer_description_set(struct peer *peer, const char *desc)
int peer_description_unset(struct peer *peer)
{
- if (peer->desc)
- XFREE(MTYPE_PEER_DESC, peer->desc);
+ XFREE(MTYPE_PEER_DESC, peer->desc);
peer->desc = NULL;
@@ -5125,15 +5111,13 @@ int peer_advertise_interval_unset(struct peer *peer)
/* neighbor interface */
void peer_interface_set(struct peer *peer, const char *str)
{
- if (peer->ifname)
- XFREE(MTYPE_BGP_PEER_IFNAME, peer->ifname);
+ XFREE(MTYPE_BGP_PEER_IFNAME, peer->ifname);
peer->ifname = XSTRDUP(MTYPE_BGP_PEER_IFNAME, str);
}
void peer_interface_unset(struct peer *peer)
{
- if (peer->ifname)
- XFREE(MTYPE_BGP_PEER_IFNAME, peer->ifname);
+ XFREE(MTYPE_BGP_PEER_IFNAME, peer->ifname);
peer->ifname = NULL;
}
diff --git a/bgpd/rfapi/bgp_rfapi_cfg.c b/bgpd/rfapi/bgp_rfapi_cfg.c
index d621d58e4..2220f0ed9 100644
--- a/bgpd/rfapi/bgp_rfapi_cfg.c
+++ b/bgpd/rfapi/bgp_rfapi_cfg.c
@@ -3457,8 +3457,7 @@ static void bgp_rfapi_delete_l2_group(struct vty *vty, /* NULL = no output */
ecommunity_free(&rfg->rt_export_list);
if (rfg->labels)
list_delete(&rfg->labels);
- if (rfg->rfp_cfg)
- XFREE(MTYPE_RFAPI_RFP_GROUP_CFG, rfg->rfp_cfg);
+ XFREE(MTYPE_RFAPI_RFP_GROUP_CFG, rfg->rfp_cfg);
listnode_delete(bgp->rfapi_cfg->l2_groups, rfg);
rfapi_l2_group_del(rfg);
@@ -3815,8 +3814,7 @@ struct rfapi_cfg *bgp_rfapi_cfg_new(struct rfapi_rfp_cfg *cfg)
struct rfapi_cfg *h;
afi_t afi;
- h = (struct rfapi_cfg *)XCALLOC(MTYPE_RFAPI_CFG,
- sizeof(struct rfapi_cfg));
+ h = XCALLOC(MTYPE_RFAPI_CFG, sizeof(struct rfapi_cfg));
assert(h);
h->nve_groups_sequential = list_new();
@@ -3878,8 +3876,7 @@ void bgp_rfapi_cfg_destroy(struct bgp *bgp, struct rfapi_cfg *h)
ecommunity_free(&h->default_rt_export_list);
if (h->default_rt_import_list)
ecommunity_free(&h->default_rt_import_list);
- if (h->default_rfp_cfg)
- XFREE(MTYPE_RFAPI_RFP_GROUP_CFG, h->default_rfp_cfg);
+ XFREE(MTYPE_RFAPI_RFP_GROUP_CFG, h->default_rfp_cfg);
for (afi = AFI_IP; afi < AFI_MAX; afi++) {
agg_table_finish(h->nve_groups_vn[afi]);
agg_table_finish(h->nve_groups_un[afi]);
diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c
index df2d404f6..93729c147 100644
--- a/bgpd/rfapi/rfapi_import.c
+++ b/bgpd/rfapi/rfapi_import.c
@@ -4285,7 +4285,7 @@ struct rfapi *bgp_rfapi_new(struct bgp *bgp)
assert(bgp->rfapi_cfg == NULL);
- h = (struct rfapi *)XCALLOC(MTYPE_RFAPI, sizeof(struct rfapi));
+ h = XCALLOC(MTYPE_RFAPI, sizeof(struct rfapi));
for (afi = AFI_IP; afi < AFI_MAX; afi++) {
h->un[afi] = agg_table_init();
diff --git a/bgpd/rfapi/vnc_debug.c b/bgpd/rfapi/vnc_debug.c
index 2b08ea493..cb9799870 100644
--- a/bgpd/rfapi/vnc_debug.c
+++ b/bgpd/rfapi/vnc_debug.c
@@ -190,7 +190,7 @@ static int bgp_vnc_config_write_debug(struct vty *vty)
int write = 0;
size_t i;
- for (i = 0; i < (sizeof(vncdebug) / sizeof(struct vnc_debug)); ++i) {
+ for (i = 0; i < array_size(vncdebug); ++i) {
if (conf_vnc_debug & vncdebug[i].bit) {
vty_out(vty, "debug bgp vnc %s\n", vncdebug[i].name);
write++;
diff --git a/bgpd/rfapi/vnc_zebra.c b/bgpd/rfapi/vnc_zebra.c
index 98f719969..b08e92296 100644
--- a/bgpd/rfapi/vnc_zebra.c
+++ b/bgpd/rfapi/vnc_zebra.c
@@ -608,10 +608,8 @@ static void vnc_zebra_add_del_prefix(struct bgp *bgp,
add);
}
- if (nhp_ary)
- XFREE(MTYPE_TMP, nhp_ary);
- if (nh_ary)
- XFREE(MTYPE_TMP, nh_ary);
+ XFREE(MTYPE_TMP, nhp_ary);
+ XFREE(MTYPE_TMP, nh_ary);
}
void vnc_zebra_add_prefix(struct bgp *bgp,
@@ -789,10 +787,8 @@ static void vnc_zebra_add_del_group_afi(struct bgp *bgp,
}
}
}
- if (nhp_ary)
- XFREE(MTYPE_TMP, nhp_ary);
- if (nh_ary)
- XFREE(MTYPE_TMP, nh_ary);
+ XFREE(MTYPE_TMP, nhp_ary);
+ XFREE(MTYPE_TMP, nh_ary);
}
}