summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@cumulusnetworks.com>2020-02-04 19:19:37 +0100
committerQuentin Young <qlyoung@cumulusnetworks.com>2020-02-04 19:19:37 +0100
commite1b36e132b7eda2d230f2f95945e231df37a42f5 (patch)
tree8a40165810e2ddc3f3d3ca0709134554b766b5ca
parent*: don't null after XFREE; XFREE does this itself (diff)
downloadfrr-e1b36e132b7eda2d230f2f95945e231df37a42f5.tar.xz
frr-e1b36e132b7eda2d230f2f95945e231df37a42f5.zip
*: remove null check before XFREE
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
-rw-r--r--bgpd/bgp_dump.c8
-rw-r--r--bgpd/bgp_filter.c4
-rw-r--r--bgpd/bgp_open.c13
-rw-r--r--bgpd/bgp_route.c4
-rw-r--r--bgpd/bgpd.c81
-rw-r--r--bgpd/bgpd.h3
-rw-r--r--bgpd/rfapi/rfapi.c4
-rw-r--r--lib/bfd.c4
-rw-r--r--lib/command.c3
-rw-r--r--lib/filter.c4
-rw-r--r--lib/plist.c4
-rw-r--r--lib/vty.c9
-rw-r--r--ospf6d/ospf6_message.c9
-rw-r--r--pimd/pim_bsm.c3
-rw-r--r--pimd/pim_msdp.c4
-rw-r--r--ripd/ripd.c3
-rw-r--r--ripngd/ripngd.c3
-rw-r--r--zebra/zebra_mlag.c15
18 files changed, 43 insertions, 135 deletions
diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c
index e9711f5b9..298f9d021 100644
--- a/bgpd/bgp_dump.c
+++ b/bgpd/bgp_dump.c
@@ -667,9 +667,7 @@ static int bgp_dump_set(struct vty *vty, struct bgp_dump *bgp_dump,
static int bgp_dump_unset(struct bgp_dump *bgp_dump)
{
/* Removing file name. */
- if (bgp_dump->filename) {
- XFREE(MTYPE_BGP_DUMP_STR, bgp_dump->filename);
- }
+ XFREE(MTYPE_BGP_DUMP_STR, bgp_dump->filename);
/* Closing file. */
if (bgp_dump->fp) {
@@ -686,9 +684,7 @@ static int bgp_dump_unset(struct bgp_dump *bgp_dump)
bgp_dump->interval = 0;
/* Removing interval string. */
- if (bgp_dump->interval_str) {
- XFREE(MTYPE_BGP_DUMP_STR, bgp_dump->interval_str);
- }
+ XFREE(MTYPE_BGP_DUMP_STR, bgp_dump->interval_str);
return CMD_SUCCESS;
}
diff --git a/bgpd/bgp_filter.c b/bgpd/bgp_filter.c
index a3c86c7ea..a03551e79 100644
--- a/bgpd/bgp_filter.c
+++ b/bgpd/bgp_filter.c
@@ -168,9 +168,7 @@ static struct as_list *as_list_new(void)
static void as_list_free(struct as_list *aslist)
{
- if (aslist->name) {
- XFREE(MTYPE_AS_STR, aslist->name);
- }
+ XFREE(MTYPE_AS_STR, aslist->name);
XFREE(MTYPE_AS_LIST, aslist);
}
diff --git a/bgpd/bgp_open.c b/bgpd/bgp_open.c
index f97827931..2d3dc1355 100644
--- a/bgpd/bgp_open.c
+++ b/bgpd/bgp_open.c
@@ -710,13 +710,8 @@ static int bgp_capability_hostname(struct peer *peer,
if (len) {
str[len] = '\0';
- if (peer->hostname != NULL) {
- XFREE(MTYPE_BGP_PEER_HOST, peer->hostname);
- }
-
- if (peer->domainname != NULL) {
- XFREE(MTYPE_BGP_PEER_HOST, peer->domainname);
- }
+ XFREE(MTYPE_BGP_PEER_HOST, peer->hostname);
+ XFREE(MTYPE_BGP_PEER_HOST, peer->domainname);
peer->hostname = XSTRDUP(MTYPE_BGP_PEER_HOST, str);
}
@@ -748,9 +743,7 @@ static int bgp_capability_hostname(struct peer *peer,
if (len) {
str[len] = '\0';
- if (peer->domainname != NULL) {
- XFREE(MTYPE_BGP_PEER_HOST, peer->domainname);
- }
+ XFREE(MTYPE_BGP_PEER_HOST, peer->domainname);
peer->domainname = XSTRDUP(MTYPE_BGP_PEER_HOST, str);
}
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 4b2db0514..954f524ec 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -12160,9 +12160,7 @@ static int bgp_distance_set(struct vty *vty, const char *distance_str,
bdistance->distance = distance;
/* Reset access-list configuration. */
- if (bdistance->access_list) {
- XFREE(MTYPE_AS_LIST, bdistance->access_list);
- }
+ XFREE(MTYPE_AS_LIST, bdistance->access_list);
if (access_list_str)
bdistance->access_list =
XSTRDUP(MTYPE_AS_LIST, access_list_str);
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 0e2bbbe7c..7c2d60c51 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -1007,22 +1007,10 @@ static void peer_free(struct peer *peer)
XFREE(MTYPE_PEER_TX_SHUTDOWN_MSG, peer->tx_shutdown_message);
- if (peer->desc) {
- XFREE(MTYPE_PEER_DESC, peer->desc);
- }
-
- /* Free allocated host character. */
- if (peer->host) {
- XFREE(MTYPE_BGP_PEER_HOST, peer->host);
- }
-
- if (peer->domainname) {
- XFREE(MTYPE_BGP_PEER_HOST, peer->domainname);
- }
-
- if (peer->ifname) {
- XFREE(MTYPE_BGP_PEER_IFNAME, peer->ifname);
- }
+ XFREE(MTYPE_PEER_DESC, peer->desc);
+ XFREE(MTYPE_BGP_PEER_HOST, peer->host);
+ XFREE(MTYPE_BGP_PEER_HOST, peer->domainname);
+ XFREE(MTYPE_BGP_PEER_IFNAME, peer->ifname);
/* Update source configuration. */
if (peer->update_source) {
@@ -1030,9 +1018,7 @@ static void peer_free(struct peer *peer)
peer->update_source = NULL;
}
- if (peer->update_if) {
- XFREE(MTYPE_PEER_UPDATE_SOURCE, peer->update_if);
- }
+ XFREE(MTYPE_PEER_UPDATE_SOURCE, peer->update_if);
XFREE(MTYPE_TMP, peer->notify.data);
memset(&peer->notify, 0, sizeof(struct bgp_notify));
@@ -1042,9 +1028,7 @@ static void peer_free(struct peer *peer)
bgp_sync_delete(peer);
- if (peer->conf_if) {
- XFREE(MTYPE_PEER_CONF_IF, peer->conf_if);
- }
+ XFREE(MTYPE_PEER_CONF_IF, peer->conf_if);
bfd_info_free(&(peer->bfd_info));
@@ -1364,9 +1348,7 @@ void peer_xfer_config(struct peer *peer_dst, struct peer *peer_src)
if (peer_src->update_source) {
if (peer_dst->update_source)
sockunion_free(peer_dst->update_source);
- if (peer_dst->update_if) {
- XFREE(MTYPE_PEER_UPDATE_SOURCE, peer_dst->update_if);
- }
+ XFREE(MTYPE_PEER_UPDATE_SOURCE, peer_dst->update_if);
peer_dst->update_source =
sockunion_dup(peer_src->update_source);
} else if (peer_src->update_if) {
@@ -2378,49 +2360,24 @@ int peer_delete(struct peer *peer)
filter = &peer->filter[afi][safi];
for (i = FILTER_IN; i < FILTER_MAX; i++) {
- if (filter->dlist[i].name) {
- XFREE(MTYPE_BGP_FILTER_NAME,
- filter->dlist[i].name);
- }
-
- if (filter->plist[i].name) {
- XFREE(MTYPE_BGP_FILTER_NAME,
- filter->plist[i].name);
- }
-
- if (filter->aslist[i].name) {
- XFREE(MTYPE_BGP_FILTER_NAME,
- filter->aslist[i].name);
- }
+ XFREE(MTYPE_BGP_FILTER_NAME, filter->dlist[i].name);
+ XFREE(MTYPE_BGP_FILTER_NAME, filter->plist[i].name);
+ XFREE(MTYPE_BGP_FILTER_NAME, filter->aslist[i].name);
}
for (i = RMAP_IN; i < RMAP_MAX; i++) {
- if (filter->map[i].name) {
- XFREE(MTYPE_BGP_FILTER_NAME,
- filter->map[i].name);
- }
+ XFREE(MTYPE_BGP_FILTER_NAME, filter->map[i].name);
}
- if (filter->usmap.name) {
- XFREE(MTYPE_BGP_FILTER_NAME, filter->usmap.name);
- }
-
- if (peer->default_rmap[afi][safi].name) {
- XFREE(MTYPE_ROUTE_MAP_NAME,
- peer->default_rmap[afi][safi].name);
- }
+ XFREE(MTYPE_BGP_FILTER_NAME, filter->usmap.name);
+ XFREE(MTYPE_ROUTE_MAP_NAME, peer->default_rmap[afi][safi].name);
}
FOREACH_AFI_SAFI (afi, safi)
peer_af_delete(peer, afi, safi);
- if (peer->hostname) {
- XFREE(MTYPE_BGP_PEER_HOST, peer->hostname);
- }
-
- if (peer->domainname) {
- XFREE(MTYPE_BGP_PEER_HOST, peer->domainname);
- }
+ XFREE(MTYPE_BGP_PEER_HOST, peer->hostname);
+ XFREE(MTYPE_BGP_PEER_HOST, peer->domainname);
peer_unlock(peer); /* initial reference */
@@ -2977,16 +2934,12 @@ static struct bgp *bgp_create(as_t *as, const char *name,
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) {
- XFREE(MTYPE_BGP_PEER_HOST, bgp->peer_self->hostname);
- }
+ XFREE(MTYPE_BGP_PEER_HOST, bgp->peer_self->hostname);
if (cmd_hostname_get())
bgp->peer_self->hostname =
XSTRDUP(MTYPE_BGP_PEER_HOST, cmd_hostname_get());
- if (bgp->peer_self->domainname != NULL) {
- XFREE(MTYPE_BGP_PEER_HOST, bgp->peer_self->domainname);
- }
+ XFREE(MTYPE_BGP_PEER_HOST, bgp->peer_self->domainname);
if (cmd_domainname_get())
bgp->peer_self->domainname =
XSTRDUP(MTYPE_BGP_PEER_HOST, cmd_domainname_get());
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index 3f33139ef..04355450d 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -1382,8 +1382,7 @@ DECLARE_QOBJ_TYPE(peer)
((peer)->attr = (group)->conf->attr)
#define PEER_STR_ATTR_INHERIT(peer, group, attr, mt) \
do { \
- if ((peer)->attr) \
- XFREE(mt, (peer)->attr); \
+ XFREE(mt, (peer)->attr); \
if ((group)->conf->attr) \
(peer)->attr = XSTRDUP(mt, (group)->conf->attr); \
else \
diff --git a/bgpd/rfapi/rfapi.c b/bgpd/rfapi/rfapi.c
index a9e60436c..4701d2e1f 100644
--- a/bgpd/rfapi/rfapi.c
+++ b/bgpd/rfapi/rfapi.c
@@ -1489,9 +1489,7 @@ void rfapiFreeBgpTeaOptionChain(struct bgp_tea_options *p)
while (p) {
next = p->next;
- if (p->value) {
- XFREE(MTYPE_BGP_TEA_OPTIONS_VALUE, p->value);
- }
+ XFREE(MTYPE_BGP_TEA_OPTIONS_VALUE, p->value);
XFREE(MTYPE_BGP_TEA_OPTIONS, p);
p = next;
diff --git a/lib/bfd.c b/lib/bfd.c
index 48d8914f6..4e192422c 100644
--- a/lib/bfd.c
+++ b/lib/bfd.c
@@ -74,9 +74,7 @@ struct bfd_info *bfd_info_create(void)
*/
void bfd_info_free(struct bfd_info **bfd_info)
{
- if (*bfd_info) {
- XFREE(MTYPE_BFD_INFO, *bfd_info);
- }
+ XFREE(MTYPE_BFD_INFO, *bfd_info);
}
/*
diff --git a/lib/command.c b/lib/command.c
index 05bb66565..8811b3a79 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -2659,8 +2659,7 @@ int cmd_banner_motd_file(const char *file)
void cmd_banner_motd_line(const char *line)
{
- if (host.motd)
- XFREE(MTYPE_HOST, host.motd);
+ XFREE(MTYPE_HOST, host.motd);
host.motd = XSTRDUP(MTYPE_HOST, line);
}
diff --git a/lib/filter.c b/lib/filter.c
index e7a225961..4521cf646 100644
--- a/lib/filter.c
+++ b/lib/filter.c
@@ -608,9 +608,7 @@ static int vty_access_list_remark_unset(struct vty *vty, afi_t afi,
return CMD_WARNING_CONFIG_FAILED;
}
- if (access->remark) {
- XFREE(MTYPE_TMP, access->remark);
- }
+ XFREE(MTYPE_TMP, access->remark);
if (access->head == NULL && access->tail == NULL)
access_list_delete(access);
diff --git a/lib/plist.c b/lib/plist.c
index 971fc6216..f6ceba81e 100644
--- a/lib/plist.c
+++ b/lib/plist.c
@@ -1092,9 +1092,7 @@ static int vty_prefix_list_desc_unset(struct vty *vty, afi_t afi,
return CMD_WARNING_CONFIG_FAILED;
}
- if (plist->desc) {
- XFREE(MTYPE_TMP, plist->desc);
- }
+ XFREE(MTYPE_TMP, plist->desc);
if (plist->head == NULL && plist->tail == NULL && plist->desc == NULL)
prefix_list_delete(plist);
diff --git a/lib/vty.c b/lib/vty.c
index 75e68c033..cf1613385 100644
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -3011,13 +3011,8 @@ void vty_reset(void)
vty_timeout_val = VTY_TIMEOUT_DEFAULT;
- if (vty_accesslist_name) {
- XFREE(MTYPE_VTY, vty_accesslist_name);
- }
-
- if (vty_ipv6_accesslist_name) {
- XFREE(MTYPE_VTY, vty_ipv6_accesslist_name);
- }
+ XFREE(MTYPE_VTY, vty_accesslist_name);
+ XFREE(MTYPE_VTY, vty_ipv6_accesslist_name);
}
static void vty_save_cwd(void)
diff --git a/ospf6d/ospf6_message.c b/ospf6d/ospf6_message.c
index 40a21b37b..d75fc39bb 100644
--- a/ospf6d/ospf6_message.c
+++ b/ospf6d/ospf6_message.c
@@ -1516,13 +1516,8 @@ int ospf6_iobuf_size(unsigned int size)
void ospf6_message_terminate(void)
{
- if (recvbuf) {
- XFREE(MTYPE_OSPF6_MESSAGE, recvbuf);
- }
-
- if (sendbuf) {
- XFREE(MTYPE_OSPF6_MESSAGE, sendbuf);
- }
+ XFREE(MTYPE_OSPF6_MESSAGE, recvbuf);
+ XFREE(MTYPE_OSPF6_MESSAGE, sendbuf);
iobuflen = 0;
}
diff --git a/pimd/pim_bsm.c b/pimd/pim_bsm.c
index 4a69e4d1a..e14b7e058 100644
--- a/pimd/pim_bsm.c
+++ b/pimd/pim_bsm.c
@@ -86,8 +86,7 @@ static void pim_free_bsgrp_node(struct route_table *rt, struct prefix *grp)
static void pim_bsm_node_free(struct bsm_info *bsm)
{
- if (bsm->bsm)
- XFREE(MTYPE_PIM_BSM_PKT_VAR_MEM, bsm->bsm);
+ XFREE(MTYPE_PIM_BSM_PKT_VAR_MEM, bsm->bsm);
XFREE(MTYPE_PIM_BSM_INFO, bsm);
}
diff --git a/pimd/pim_msdp.c b/pimd/pim_msdp.c
index 58ebc6ce6..bb02a36e1 100644
--- a/pimd/pim_msdp.c
+++ b/pimd/pim_msdp.c
@@ -1175,9 +1175,7 @@ static void pim_msdp_peer_free(struct pim_msdp_peer *mp)
stream_fifo_free(mp->obuf);
}
- if (mp->mesh_group_name) {
- XFREE(MTYPE_PIM_MSDP_MG_NAME, mp->mesh_group_name);
- }
+ XFREE(MTYPE_PIM_MSDP_MG_NAME, mp->mesh_group_name);
mp->pim = NULL;
XFREE(MTYPE_PIM_MSDP_PEER, mp);
diff --git a/ripd/ripd.c b/ripd/ripd.c
index ec0770ef3..99f48dffd 100644
--- a/ripd/ripd.c
+++ b/ripd/ripd.c
@@ -3670,8 +3670,7 @@ static int rip_vrf_enable(struct vrf *vrf)
running_config->version++;
}
}
- if (old_vrf_name)
- XFREE(MTYPE_RIP_VRF_NAME, old_vrf_name);
+ XFREE(MTYPE_RIP_VRF_NAME, old_vrf_name);
}
if (!rip || rip->enabled)
return 0;
diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c
index ad2ddd0db..f8d7dc968 100644
--- a/ripngd/ripngd.c
+++ b/ripngd/ripngd.c
@@ -2804,8 +2804,7 @@ static int ripng_vrf_enable(struct vrf *vrf)
running_config->version++;
}
}
- if (old_vrf_name)
- XFREE(MTYPE_RIPNG_VRF_NAME, old_vrf_name);
+ XFREE(MTYPE_RIPNG_VRF_NAME, old_vrf_name);
}
if (ripng->enabled)
diff --git a/zebra/zebra_mlag.c b/zebra/zebra_mlag.c
index f6bd5f458..fc7804a40 100644
--- a/zebra/zebra_mlag.c
+++ b/zebra/zebra_mlag.c
@@ -797,13 +797,11 @@ int zebra_mlag_protobuf_encode_client_data(struct stream *s, uint32_t *msg_type)
}
for (i = 0; i < mlag_msg.msg_cnt; i++) {
- if (pay_load[i]->vrf_name)
- XFREE(MTYPE_MLAG_PBUF, pay_load[i]->vrf_name);
+ XFREE(MTYPE_MLAG_PBUF, pay_load[i]->vrf_name);
if (pay_load[i]->owner_id == MLAG_OWNER_INTERFACE
&& pay_load[i]->intf_name)
XFREE(MTYPE_MLAG_PBUF, pay_load[i]->intf_name);
- if (pay_load[i])
- XFREE(MTYPE_MLAG_PBUF, pay_load[i]);
+ XFREE(MTYPE_MLAG_PBUF, pay_load[i]);
}
XFREE(MTYPE_MLAG_PBUF, pay_load);
if (cleanup == true)
@@ -861,13 +859,11 @@ int zebra_mlag_protobuf_encode_client_data(struct stream *s, uint32_t *msg_type)
}
for (i = 0; i < mlag_msg.msg_cnt; i++) {
- if (pay_load[i]->vrf_name)
- XFREE(MTYPE_MLAG_PBUF, pay_load[i]->vrf_name);
+ XFREE(MTYPE_MLAG_PBUF, pay_load[i]->vrf_name);
if (pay_load[i]->owner_id == MLAG_OWNER_INTERFACE
&& pay_load[i]->intf_name)
XFREE(MTYPE_MLAG_PBUF, pay_load[i]->intf_name);
- if (pay_load[i])
- XFREE(MTYPE_MLAG_PBUF, pay_load[i]);
+ XFREE(MTYPE_MLAG_PBUF, pay_load[i]);
}
XFREE(MTYPE_MLAG_PBUF, pay_load);
if (cleanup)
@@ -914,8 +910,7 @@ int zebra_mlag_protobuf_encode_client_data(struct stream *s, uint32_t *msg_type)
mlag_lib_msgid_to_str(mlag_msg.msg_type, buf,
sizeof(buf)),
len);
- if (hdr.data.data)
- XFREE(MTYPE_MLAG_PBUF, hdr.data.data);
+ XFREE(MTYPE_MLAG_PBUF, hdr.data.data);
return len;
}