Fix up the assignment of the variable = RB_ROOT inside of
while loop patter we were using.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
15 files changed:
ia = iface_af_get(iface, af);
if_stop_hello_timer(ia);
ia = iface_af_get(iface, af);
if_stop_hello_timer(ia);
- while ((adj = RB_ROOT(ia_adj_head, &ia->adj_tree)) != NULL)
+ while (!RB_EMPTY(ia_adj_head, &ia->adj_tree)) {
+ adj = RB_ROOT(ia_adj_head, &ia->adj_tree);
+
adj_del(adj, S_SHUTDOWN);
adj_del(adj, S_SHUTDOWN);
/* try to cleanup */
switch (af) {
/* try to cleanup */
switch (af) {
struct l2vpn_if *lif;
struct l2vpn_pw *pw;
struct l2vpn_if *lif;
struct l2vpn_pw *pw;
- while ((lif = RB_ROOT(l2vpn_if_head, &l2vpn->if_tree)) != NULL) {
+ while (!RB_EMPTY(l2vpn_if_head, &l2vpn->if_tree)) {
+ lif = RB_ROOT(l2vpn_if_head, &l2vpn->if_tree);
+
RB_REMOVE(l2vpn_if_head, &l2vpn->if_tree, lif);
free(lif);
}
RB_REMOVE(l2vpn_if_head, &l2vpn->if_tree, lif);
free(lif);
}
- while ((pw = RB_ROOT(l2vpn_pw_head, &l2vpn->pw_tree)) != NULL) {
+ while (!RB_EMPTY(l2vpn_pw_head, &l2vpn->pw_tree)) {
+ pw = RB_ROOT(l2vpn_pw_head, &l2vpn->pw_tree);
+
RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_tree, pw);
free(pw);
}
RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_tree, pw);
free(pw);
}
- while ((pw = RB_ROOT(l2vpn_pw_head,
- &l2vpn->pw_inactive_tree)) != NULL) {
+ while (!RB_EMPTY(l2vpn_pw_head, &l2vpn->pw_inactive_tree)) {
+ pw = RB_ROOT(l2vpn_pw_head, &l2vpn->pw_inactive_tree);
+
RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_inactive_tree, pw);
free(pw);
}
RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_inactive_tree, pw);
free(pw);
}
- while ((ln = RB_ROOT(nbr_tree, &lde_nbrs)) != NULL)
+ while (!RB_EMPTY(nbr_tree, &lde_nbrs)) {
+ ln = RB_ROOT(nbr_tree, &lde_nbrs);
+
- while ((f = RB_ROOT(fec_tree, fh)) != NULL) {
+ while (!RB_EMPTY(fec_tree, fh)) {
+ f = RB_ROOT(fec_tree, fh);
+
fec_remove(fh, f);
free_cb(f);
}
fec_remove(fh, f);
free_cb(f);
}
struct l2vpn_if *lif;
struct l2vpn_pw *pw;
struct l2vpn_if *lif;
struct l2vpn_pw *pw;
- while ((lif = RB_ROOT(l2vpn_if_head, &l2vpn->if_tree)) != NULL) {
+ while (!RB_EMPTY(l2vpn_if_head, &l2vpn->if_tree)) {
+ lif = RB_ROOT(l2vpn_if_head, &l2vpn->if_tree);
+
QOBJ_UNREG(lif);
RB_REMOVE(l2vpn_if_head, &l2vpn->if_tree, lif);
free(lif);
}
QOBJ_UNREG(lif);
RB_REMOVE(l2vpn_if_head, &l2vpn->if_tree, lif);
free(lif);
}
- while ((pw = RB_ROOT(l2vpn_pw_head, &l2vpn->pw_tree)) != NULL) {
+ while (!RB_EMPTY(l2vpn_pw_head, &l2vpn->pw_tree)) {
+ pw = RB_ROOT(l2vpn_pw_head, &l2vpn->pw_tree);
+
QOBJ_UNREG(pw);
RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_tree, pw);
free(pw);
}
QOBJ_UNREG(pw);
RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_tree, pw);
free(pw);
}
- while ((pw = RB_ROOT(l2vpn_pw_head,
- &l2vpn->pw_inactive_tree)) != NULL) {
+ while (!RB_EMPTY(l2vpn_pw_head, &l2vpn->pw_inactive_tree)) {
+ pw = RB_ROOT(l2vpn_pw_head, &l2vpn->pw_inactive_tree);
+
QOBJ_UNREG(pw);
RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_inactive_tree, pw);
free(pw);
QOBJ_UNREG(pw);
RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_inactive_tree, pw);
free(pw);
struct iface *iface;
struct nbr_params *nbrp;
struct iface *iface;
struct nbr_params *nbrp;
- while ((iface = RB_ROOT(iface_head, &conf->iface_tree)) != NULL) {
+ while (!RB_EMPTY(iface_head, &conf->iface_tree)) {
+ iface = RB_ROOT(iface_head, &conf->iface_tree);
+
QOBJ_UNREG(iface);
RB_REMOVE(iface_head, &conf->iface_tree, iface);
free(iface);
}
QOBJ_UNREG(iface);
RB_REMOVE(iface_head, &conf->iface_tree, iface);
free(iface);
}
- while ((nbrp = RB_ROOT(nbrp_head, &conf->nbrp_tree)) != NULL) {
+ while (!RB_EMPTY(nbrp_head, &conf->nbrp_tree)) {
+ nbrp = RB_ROOT(nbrp_head, &conf->nbrp_tree);
+
QOBJ_UNREG(nbrp);
RB_REMOVE(nbrp_head, &conf->nbrp_tree, nbrp);
free(nbrp);
QOBJ_UNREG(nbrp);
RB_REMOVE(nbrp_head, &conf->nbrp_tree, nbrp);
free(nbrp);
struct l2vpn_if *lif;
struct l2vpn_pw *pw;
struct l2vpn_if *lif;
struct l2vpn_pw *pw;
- while ((l2vpn = RB_ROOT(l2vpn_head, &conf->l2vpn_tree)) != NULL) {
- while ((lif = RB_ROOT(l2vpn_if_head,
- &l2vpn->if_tree)) != NULL) {
+ while (!RB_EMPTY(l2vpn_head, &conf->l2vpn_tree)) {
+ l2vpn = RB_ROOT(l2vpn_head, &conf->l2vpn_tree);
+ while (!RB_EMPTY(l2vpn_if_head, &l2vpn->if_tree)) {
+ lif = RB_ROOT(l2vpn_if_head, &l2vpn->if_tree);
+
QOBJ_UNREG(lif);
RB_REMOVE(l2vpn_if_head, &l2vpn->if_tree, lif);
free(lif);
}
QOBJ_UNREG(lif);
RB_REMOVE(l2vpn_if_head, &l2vpn->if_tree, lif);
free(lif);
}
- while ((pw = RB_ROOT(l2vpn_pw_head, &l2vpn->pw_tree)) != NULL) {
+ while (!RB_EMPTY(l2vpn_pw_head, &l2vpn->pw_tree)) {
+ pw = RB_ROOT(l2vpn_pw_head, &l2vpn->pw_tree);
+
QOBJ_UNREG(pw);
RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_tree, pw);
free(pw);
}
QOBJ_UNREG(pw);
RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_tree, pw);
free(pw);
}
- while ((pw = RB_ROOT(l2vpn_pw_head,
- &l2vpn->pw_inactive_tree)) != NULL) {
+ while (!RB_EMPTY(l2vpn_pw_head, &l2vpn->pw_inactive_tree)) {
+ pw = RB_ROOT(l2vpn_pw_head, &l2vpn->pw_inactive_tree);
+
QOBJ_UNREG(pw);
RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_inactive_tree, pw);
free(pw);
QOBJ_UNREG(pw);
RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_inactive_tree, pw);
free(pw);
struct nbr_params *nbrp;
struct l2vpn *l2vpn;
struct nbr_params *nbrp;
struct l2vpn *l2vpn;
- while ((iface = RB_ROOT(iface_head, &xconf->iface_tree)) != NULL) {
+ while (!RB_EMPTY(iface_head, &xconf->iface_tree)) {
+ iface = RB_ROOT(iface_head, &xconf->iface_tree);
+
RB_REMOVE(iface_head, &xconf->iface_tree, iface);
free(iface);
}
RB_REMOVE(iface_head, &xconf->iface_tree, iface);
free(iface);
}
- while ((tnbr = RB_ROOT(tnbr_head, &xconf->tnbr_tree)) != NULL) {
+ while (!RB_EMPTY(tnbr_head, &xconf->tnbr_tree)) {
+ tnbr = RB_ROOT(tnbr_head, &xconf->tnbr_tree);
+
RB_REMOVE(tnbr_head, &xconf->tnbr_tree, tnbr);
free(tnbr);
}
RB_REMOVE(tnbr_head, &xconf->tnbr_tree, tnbr);
free(tnbr);
}
- while ((nbrp = RB_ROOT(nbrp_head, &xconf->nbrp_tree)) != NULL) {
+ while (!RB_EMPTY(nbrp_head, &xconf->nbrp_tree)) {
+ nbrp = RB_ROOT(nbrp_head, &xconf->nbrp_tree);
+
RB_REMOVE(nbrp_head, &xconf->nbrp_tree, nbrp);
free(nbrp);
}
RB_REMOVE(nbrp_head, &xconf->nbrp_tree, nbrp);
free(nbrp);
}
- while ((l2vpn = RB_ROOT(l2vpn_head, &xconf->l2vpn_tree)) != NULL) {
+ while (!RB_EMPTY(l2vpn_head, &xconf->l2vpn_tree)) {
+ l2vpn = RB_ROOT(l2vpn_head, &xconf->l2vpn_tree);
+
RB_REMOVE(l2vpn_head, &xconf->l2vpn_tree, l2vpn);
l2vpn_del(l2vpn);
}
RB_REMOVE(l2vpn_head, &xconf->l2vpn_tree, l2vpn);
l2vpn_del(l2vpn);
}
assert(if_addr != LIST_FIRST(&global.addr_list));
free(if_addr);
}
assert(if_addr != LIST_FIRST(&global.addr_list));
free(if_addr);
}
- while ((adj = RB_ROOT(global_adj_head, &global.adj_tree)) != NULL)
+ while (!RB_EMPTY(global_adj_head, &global.adj_tree)) {
+ adj = RB_ROOT(global_adj_head, &global.adj_tree);
+
adj_del(adj, S_SHUTDOWN);
adj_del(adj, S_SHUTDOWN);
/* clean up */
if (iev_lde)
/* clean up */
if (iev_lde)
mapping_list_clr(&nbr->release_list);
mapping_list_clr(&nbr->abortreq_list);
mapping_list_clr(&nbr->release_list);
mapping_list_clr(&nbr->abortreq_list);
- while ((adj = RB_ROOT(nbr_adj_head, &nbr->adj_tree)) != NULL) {
+ while (!RB_EMPTY(nbr_adj_head, &nbr->adj_tree)) {
+ adj = RB_ROOT(nbr_adj_head, &nbr->adj_tree);
+
adj->nbr = NULL;
RB_REMOVE(nbr_adj_head, &nbr->adj_tree, adj);
}
adj->nbr = NULL;
RB_REMOVE(nbr_adj_head, &nbr->adj_tree, adj);
}
rn = route_node_lookup (ifaddr_ipv4_table, (struct prefix *) &p);
if (! rn)
return NULL;
rn = route_node_lookup (ifaddr_ipv4_table, (struct prefix *) &p);
if (! rn)
return NULL;
ifp = rn->info;
route_unlock_node (rn);
return ifp;
ifp = rn->info;
route_unlock_node (rn);
return ifp;
- while ((ifp = RB_ROOT(if_name_head, &vrf->ifaces_by_name)) != NULL) {
+ while (!RB_EMPTY(if_name_head, &vrf->ifaces_by_name)) {
+ ifp = RB_ROOT(if_name_head, &vrf->ifaces_by_name);
+
if (ifp->node) {
ifp->node->info = NULL;
route_unlock_node(ifp->node);
if (ifp->node) {
ifp->node->info = NULL;
route_unlock_node(ifp->node);
- while ((ns = RB_ROOT(ns_head, &ns_tree)) != NULL)
+ while (!RB_EMPTY(ns_head, &ns_tree)) {
+ ns = RB_ROOT(ns_head, &ns_tree);
+
}
/* Create a socket for the NS. */
}
/* Create a socket for the NS. */
zlog_debug("%s: Shutting down vrf subsystem",
__PRETTY_FUNCTION__);
zlog_debug("%s: Shutting down vrf subsystem",
__PRETTY_FUNCTION__);
- while ((vrf = RB_ROOT(vrf_id_head, &vrfs_by_id)) != NULL) {
+ while (!RB_EMPTY(vrf_id_head, &vrfs_by_id)) {
+ vrf = RB_ROOT(vrf_id_head, &vrfs_by_id);
+
/* Clear configured flag and invoke delete. */
UNSET_FLAG(vrf->status, VRF_CONFIGURED);
vrf_delete(vrf);
}
/* Clear configured flag and invoke delete. */
UNSET_FLAG(vrf->status, VRF_CONFIGURED);
vrf_delete(vrf);
}
- while ((vrf = RB_ROOT(vrf_name_head, &vrfs_by_name)) != NULL) {
+
+ while (!RB_EMPTY(vrf_name_head, &vrfs_by_name)) {
+ vrf = RB_ROOT(vrf_name_head, &vrfs_by_name);
+
/* Clear configured flag and invoke delete. */
UNSET_FLAG(vrf->status, VRF_CONFIGURED);
vrf_delete(vrf);
/* Clear configured flag and invoke delete. */
UNSET_FLAG(vrf->status, VRF_CONFIGURED);
vrf_delete(vrf);
if (pim_ifp->sec_addr_list)
list_delete_and_null(&pim_ifp->sec_addr_list);
if (pim_ifp->sec_addr_list)
list_delete_and_null(&pim_ifp->sec_addr_list);
- while ((ch = RB_ROOT(pim_ifchannel_rb,
- &pim_ifp->ifchannel_rb)) != NULL)
+ while (!RB_EMPTY(pim_ifchannel_rb, &pim_ifp->ifchannel_rb)) {
+ ch = RB_ROOT(pim_ifchannel_rb, &pim_ifp->ifchannel_rb);
+
pim_ifchannel_delete(ch);
pim_ifchannel_delete(ch);
XFREE(MTYPE_PIM_INTERFACE, pim_ifp);
XFREE(MTYPE_PIM_INTERFACE, pim_ifp);
if (pim_ifp->boundary_oil_plist)
XFREE(MTYPE_PIM_INTERFACE, pim_ifp->boundary_oil_plist);
if (pim_ifp->boundary_oil_plist)
XFREE(MTYPE_PIM_INTERFACE, pim_ifp->boundary_oil_plist);
- while ((ch = RB_ROOT(pim_ifchannel_rb,
- &pim_ifp->ifchannel_rb)) != NULL)
+ while (!RB_EMPTY(pim_ifchannel_rb, &pim_ifp->ifchannel_rb)) {
+ ch = RB_ROOT(pim_ifchannel_rb, &pim_ifp->ifchannel_rb);
+
pim_ifchannel_delete(ch);
pim_ifchannel_delete(ch);
XFREE(MTYPE_PIM_INTERFACE, pim_ifp);
XFREE(MTYPE_PIM_INTERFACE, pim_ifp);
- while ((ch = RB_ROOT(pim_ifchannel_rb,
- &pim_ifp->ifchannel_rb)) != NULL) {
+ while (!RB_EMPTY(pim_ifchannel_rb, &pim_ifp->ifchannel_rb)) {
+ ch = RB_ROOT(pim_ifchannel_rb, &pim_ifp->ifchannel_rb);
+
pim_ifchannel_delete(ch);
}
}
pim_ifchannel_delete(ch);
}
}
struct route_table *zebra_ns_find_table(struct zebra_ns *zns,
uint32_t tableid, afi_t afi)
{
struct route_table *zebra_ns_find_table(struct zebra_ns *zns,
uint32_t tableid, afi_t afi)
{
- struct zebra_ns_tables finder;
- struct zebra_ns_tables *znst;
+ struct zebra_ns_table finder;
+ struct zebra_ns_table *znst;
memset(&finder, 0, sizeof(finder));
finder.afi = afi;
finder.tableid = tableid;
memset(&finder, 0, sizeof(finder));
finder.afi = afi;
finder.tableid = tableid;
- znst = RB_FIND(zebra_ns_tables_head, &zns->ns_tables, &finder);
+ znst = RB_FIND(zebra_ns_table_head, &zns->ns_tables, &finder);
if (znst)
return znst->table;
if (znst)
return znst->table;
struct zebra_ns_table *znst;
struct zebra_ns *zns = (struct zebra_ns *)(*info);
struct zebra_ns_table *znst;
struct zebra_ns *zns = (struct zebra_ns *)(*info);
- while ((znst = RB_ROOT(zebra_ns_table_head, &zns->ns_tables))
- != NULL) {
+ while (!RB_EMPTY(zebra_ns_table_head, &zns->ns_tables)) {
+ znst = RB_ROOT(zebra_ns_table_head, &zns->ns_tables);
+
RB_REMOVE(zebra_ns_table_head, &zns->ns_tables, znst);
znst = zebra_ns_free_table(znst);
}
RB_REMOVE(zebra_ns_table_head, &zns->ns_tables, znst);
znst = zebra_ns_free_table(znst);
}
- while ((pw = RB_ROOT(zebra_pw_head, &zvrf->pseudowires)) != NULL)
+ while (!RB_EMPTY(zebra_pw_head, &zvrf->pseudowires)) {
+ pw = RB_ROOT(zebra_pw_head, &zvrf->pseudowires);
+
}
DEFUN_NOSH (pseudowire_if,
}
DEFUN_NOSH (pseudowire_if,