summaryrefslogtreecommitdiff
path: root/ofproto
diff options
context:
space:
mode:
authorAdrian Moreno <amorenoz@redhat.com>2022-03-23 12:56:17 +0100
committerIlya Maximets <i.maximets@ovn.org>2022-03-30 16:59:02 +0200
commit9e56549c2bba79e644de2d3876b363553175210c (patch)
treebf0bf39f86c3e63eda7171f727a6ca3dcc69922b /ofproto
parent860e69a8c3d6994dc000b37d682bd16cd2925bef (diff)
downloadopenvswitch-9e56549c2bba79e644de2d3876b363553175210c.tar.gz
hmap: use short version of safe loops if possible.
Using SHORT version of the *_SAFE loops makes the code cleaner and less error prone. So, use the SHORT version and remove the extra variable when possible for hmap and all its derived types. In order to be able to use both long and short versions without changing the name of the macro for all the clients, overload the existing name and select the appropriate version depending on the number of arguments. Acked-by: Dumitru Ceara <dceara@redhat.com> Acked-by: Eelco Chaudron <echaudro@redhat.com> Signed-off-by: Adrian Moreno <amorenoz@redhat.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Diffstat (limited to 'ofproto')
-rw-r--r--ofproto/bond.c4
-rw-r--r--ofproto/connmgr.c20
-rw-r--r--ofproto/in-band.c4
-rw-r--r--ofproto/netflow.c8
-rw-r--r--ofproto/ofproto-dpif-ipfix.c8
-rw-r--r--ofproto/ofproto-dpif-sflow.c4
-rw-r--r--ofproto/ofproto-dpif-xlate.c8
-rw-r--r--ofproto/ofproto-dpif.c4
-rw-r--r--ofproto/ofproto.c16
9 files changed, 38 insertions, 38 deletions
diff --git a/ofproto/bond.c b/ofproto/bond.c
index 1a3d75b35..845f69e21 100644
--- a/ofproto/bond.c
+++ b/ofproto/bond.c
@@ -338,7 +338,7 @@ static void
update_recirc_rules__(struct bond *bond)
{
struct match match;
- struct bond_pr_rule_op *pr_op, *next_op;
+ struct bond_pr_rule_op *pr_op;
uint64_t ofpacts_stub[128 / 8];
struct ofpbuf ofpacts;
int i;
@@ -372,7 +372,7 @@ update_recirc_rules__(struct bond *bond)
ofpbuf_use_stub(&ofpacts, ofpacts_stub, sizeof ofpacts_stub);
- HMAP_FOR_EACH_SAFE(pr_op, next_op, hmap_node, &bond->pr_rule_ops) {
+ HMAP_FOR_EACH_SAFE (pr_op, hmap_node, &bond->pr_rule_ops) {
int error;
switch (pr_op->op) {
case ADD:
diff --git a/ofproto/connmgr.c b/ofproto/connmgr.c
index 5666d7283..172a58cfb 100644
--- a/ofproto/connmgr.c
+++ b/ofproto/connmgr.c
@@ -310,8 +310,8 @@ connmgr_destroy(struct connmgr *mgr)
return;
}
- struct ofservice *ofservice, *next_ofservice;
- HMAP_FOR_EACH_SAFE (ofservice, next_ofservice, hmap_node, &mgr->services) {
+ struct ofservice *ofservice;
+ HMAP_FOR_EACH_SAFE (ofservice, hmap_node, &mgr->services) {
ofservice_destroy(ofservice);
}
hmap_destroy(&mgr->services);
@@ -592,8 +592,8 @@ connmgr_set_controllers(struct connmgr *mgr, struct shash *controllers)
/* Delete services that are no longer configured.
* Update configuration of all now-existing services. */
- struct ofservice *ofservice, *next_ofservice;
- HMAP_FOR_EACH_SAFE (ofservice, next_ofservice, hmap_node, &mgr->services) {
+ struct ofservice *ofservice;
+ HMAP_FOR_EACH_SAFE (ofservice, hmap_node, &mgr->services) {
const char *target = ofservice->target;
struct ofproto_controller *c = shash_find_data(controllers, target);
if (!c) {
@@ -1137,9 +1137,9 @@ ofconn_remove_bundle(struct ofconn *ofconn, struct ofp_bundle *bundle)
static void
bundle_remove_all(struct ofconn *ofconn)
{
- struct ofp_bundle *b, *next;
+ struct ofp_bundle *b;
- HMAP_FOR_EACH_SAFE (b, next, node, &ofconn->bundles) {
+ HMAP_FOR_EACH_SAFE (b, node, &ofconn->bundles) {
ofp_bundle_remove__(ofconn, b);
}
}
@@ -1149,8 +1149,8 @@ bundle_remove_expired(struct ofconn *ofconn, long long int now)
{
long long int limit = now - bundle_idle_timeout;
- struct ofp_bundle *b, *next;
- HMAP_FOR_EACH_SAFE (b, next, node, &ofconn->bundles) {
+ struct ofp_bundle *b;
+ HMAP_FOR_EACH_SAFE (b, node, &ofconn->bundles) {
if (b->used <= limit) {
ofconn_send_error(ofconn, b->msg, OFPERR_OFPBFC_TIMEOUT);
ofp_bundle_remove__(ofconn, b);
@@ -1247,8 +1247,8 @@ ofconn_destroy(struct ofconn *ofconn)
free(ofconn->async_cfg);
- struct ofmonitor *monitor, *next_monitor;
- HMAP_FOR_EACH_SAFE (monitor, next_monitor, ofconn_node,
+ struct ofmonitor *monitor;
+ HMAP_FOR_EACH_SAFE (monitor, ofconn_node,
&ofconn->monitors) {
ofmonitor_destroy(monitor);
}
diff --git a/ofproto/in-band.c b/ofproto/in-band.c
index 82d8dfa14..3992251f5 100644
--- a/ofproto/in-band.c
+++ b/ofproto/in-band.c
@@ -377,7 +377,7 @@ in_band_run(struct in_band *ib)
uint64_t ofpacts_stub[128 / 8];
struct ofpbuf ofpacts;
- struct in_band_rule *rule, *next;
+ struct in_band_rule *rule;
ofpbuf_use_stub(&ofpacts, ofpacts_stub, sizeof ofpacts_stub);
@@ -391,7 +391,7 @@ in_band_run(struct in_band *ib)
update_rules(ib);
- HMAP_FOR_EACH_SAFE (rule, next, hmap_node, &ib->rules) {
+ HMAP_FOR_EACH_SAFE (rule, hmap_node, &ib->rules) {
switch (rule->op) {
case ADD:
ofproto_add_flow(ib->ofproto, &rule->match, rule->priority,
diff --git a/ofproto/netflow.c b/ofproto/netflow.c
index ed58de17d..aad9f9c77 100644
--- a/ofproto/netflow.c
+++ b/ofproto/netflow.c
@@ -299,7 +299,7 @@ static void
netflow_run__(struct netflow *nf) OVS_REQUIRES(mutex)
{
long long int now = time_msec();
- struct netflow_flow *nf_flow, *next;
+ struct netflow_flow *nf_flow;
if (nf->packet.size) {
collectors_send(nf->collectors, nf->packet.data, nf->packet.size);
@@ -312,7 +312,7 @@ netflow_run__(struct netflow *nf) OVS_REQUIRES(mutex)
nf->next_timeout = now + 1000;
- HMAP_FOR_EACH_SAFE (nf_flow, next, hmap_node, &nf->flows) {
+ HMAP_FOR_EACH_SAFE (nf_flow, hmap_node, &nf->flows) {
if (now > nf_flow->last_expired + nf->active_timeout) {
bool idle = nf_flow->used < nf_flow->last_expired;
netflow_expire__(nf, nf_flow);
@@ -416,8 +416,8 @@ netflow_unref(struct netflow *nf)
collectors_destroy(nf->collectors);
ofpbuf_uninit(&nf->packet);
- struct netflow_flow *nf_flow, *next;
- HMAP_FOR_EACH_SAFE (nf_flow, next, hmap_node, &nf->flows) {
+ struct netflow_flow *nf_flow;
+ HMAP_FOR_EACH_SAFE (nf_flow, hmap_node, &nf->flows) {
hmap_remove(&nf->flows, &nf_flow->hmap_node);
free(nf_flow);
}
diff --git a/ofproto/ofproto-dpif-ipfix.c b/ofproto/ofproto-dpif-ipfix.c
index ff4b6339a..fc927fe86 100644
--- a/ofproto/ofproto-dpif-ipfix.c
+++ b/ofproto/ofproto-dpif-ipfix.c
@@ -1078,7 +1078,7 @@ dpif_ipfix_set_options(
{
int i;
struct ofproto_ipfix_flow_exporter_options *options;
- struct dpif_ipfix_flow_exporter_map_node *node, *next;
+ struct dpif_ipfix_flow_exporter_map_node *node;
ovs_mutex_lock(&mutex);
dpif_ipfix_bridge_exporter_set_options(&di->bridge_exporter,
@@ -1103,7 +1103,7 @@ dpif_ipfix_set_options(
}
/* Remove dropped flow exporters, if any needs to be removed. */
- HMAP_FOR_EACH_SAFE (node, next, node, &di->flow_exporter_map) {
+ HMAP_FOR_EACH_SAFE (node, node, &di->flow_exporter_map) {
/* This is slow but doesn't take any extra memory, and
* this table is not supposed to contain many rows anyway. */
options = (struct ofproto_ipfix_flow_exporter_options *)
@@ -1215,7 +1215,7 @@ static void
dpif_ipfix_clear(struct dpif_ipfix *di) OVS_REQUIRES(mutex)
{
struct dpif_ipfix_flow_exporter_map_node *exp_node;
- struct dpif_ipfix_port *dip, *next;
+ struct dpif_ipfix_port *dip;
dpif_ipfix_bridge_exporter_clear(&di->bridge_exporter);
@@ -1224,7 +1224,7 @@ dpif_ipfix_clear(struct dpif_ipfix *di) OVS_REQUIRES(mutex)
free(exp_node);
}
- HMAP_FOR_EACH_SAFE (dip, next, hmap_node, &di->ports) {
+ HMAP_FOR_EACH_SAFE (dip, hmap_node, &di->ports) {
dpif_ipfix_del_port__(di, dip);
}
}
diff --git a/ofproto/ofproto-dpif-sflow.c b/ofproto/ofproto-dpif-sflow.c
index 5538a47a1..ab4941364 100644
--- a/ofproto/ofproto-dpif-sflow.c
+++ b/ofproto/ofproto-dpif-sflow.c
@@ -591,10 +591,10 @@ void
dpif_sflow_unref(struct dpif_sflow *ds) OVS_EXCLUDED(mutex)
{
if (ds && ovs_refcount_unref_relaxed(&ds->ref_cnt) == 1) {
- struct dpif_sflow_port *dsp, *next;
+ struct dpif_sflow_port *dsp;
dpif_sflow_clear(ds);
- HMAP_FOR_EACH_SAFE (dsp, next, hmap_node, &ds->ports) {
+ HMAP_FOR_EACH_SAFE (dsp, hmap_node, &ds->ports) {
dpif_sflow_del_port__(ds, dsp);
}
hmap_destroy(&ds->ports);
diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index 922e02e97..bfd4960dd 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -1222,13 +1222,13 @@ xlate_txn_start(void)
static void
xlate_xcfg_free(struct xlate_cfg *xcfg)
{
- struct xbridge *xbridge, *next_xbridge;
+ struct xbridge *xbridge;
if (!xcfg) {
return;
}
- HMAP_FOR_EACH_SAFE (xbridge, next_xbridge, hmap_node, &xcfg->xbridges) {
+ HMAP_FOR_EACH_SAFE (xbridge, hmap_node, &xcfg->xbridges) {
xlate_xbridge_remove(xcfg, xbridge);
}
@@ -1283,13 +1283,13 @@ static void
xlate_xbridge_remove(struct xlate_cfg *xcfg, struct xbridge *xbridge)
{
struct xbundle *xbundle;
- struct xport *xport, *next_xport;
+ struct xport *xport;
if (!xbridge) {
return;
}
- HMAP_FOR_EACH_SAFE (xport, next_xport, ofp_node, &xbridge->xports) {
+ HMAP_FOR_EACH_SAFE (xport, ofp_node, &xbridge->xports) {
xlate_xport_remove(xcfg, xport);
}
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 9d4d55afb..696957024 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -1659,7 +1659,7 @@ static int
construct(struct ofproto *ofproto_)
{
struct ofproto_dpif *ofproto = ofproto_dpif_cast(ofproto_);
- struct shash_node *node, *next;
+ struct shash_node *node;
int error;
/* Tunnel module can get used right after the udpif threads are running. */
@@ -1697,7 +1697,7 @@ construct(struct ofproto *ofproto_)
ofproto->ams_seqno = seq_read(ofproto->ams_seq);
- SHASH_FOR_EACH_SAFE (node, next, &init_ofp_ports) {
+ SHASH_FOR_EACH_SAFE (node, &init_ofp_ports) {
struct iface_hint *iface_hint = node->data;
if (!strcmp(iface_hint->br_name, ofproto->up.name)) {
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 7e09a588a..2ed107800 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -1754,7 +1754,7 @@ void
ofproto_destroy(struct ofproto *p, bool del)
OVS_EXCLUDED(ofproto_mutex)
{
- struct ofport *ofport, *next_ofport;
+ struct ofport *ofport;
struct ofport_usage *usage;
if (!p) {
@@ -1762,7 +1762,7 @@ ofproto_destroy(struct ofproto *p, bool del)
}
ofproto_flush__(p, del);
- HMAP_FOR_EACH_SAFE (ofport, next_ofport, hmap_node, &p->ports) {
+ HMAP_FOR_EACH_SAFE (ofport, hmap_node, &p->ports) {
ofport_destroy(ofport, del);
}
@@ -2826,7 +2826,7 @@ init_ports(struct ofproto *p)
{
struct ofproto_port_dump dump;
struct ofproto_port ofproto_port;
- struct shash_node *node, *next;
+ struct shash_node *node;
OFPROTO_PORT_FOR_EACH (&ofproto_port, &dump, p) {
const char *name = ofproto_port.name;
@@ -2857,7 +2857,7 @@ init_ports(struct ofproto *p)
}
}
- SHASH_FOR_EACH_SAFE(node, next, &init_ofp_ports) {
+ SHASH_FOR_EACH_SAFE (node, &init_ofp_ports) {
struct iface_hint *iface_hint = node->data;
if (!strcmp(iface_hint->br_name, p->name)) {
@@ -6852,9 +6852,9 @@ static void
meter_delete_all(struct ofproto *ofproto)
OVS_REQUIRES(ofproto_mutex)
{
- struct meter *meter, *next;
+ struct meter *meter;
- HMAP_FOR_EACH_SAFE (meter, next, node, &ofproto->meters) {
+ HMAP_FOR_EACH_SAFE (meter, node, &ofproto->meters) {
hmap_remove(&ofproto->meters, &meter->node);
meter_destroy(ofproto, meter);
}
@@ -9199,8 +9199,8 @@ oftable_configure_eviction(struct oftable *table, unsigned int eviction,
/* Destroy existing eviction groups, then destroy and recreate data
* structures to recover memory. */
- struct eviction_group *evg, *next;
- HMAP_FOR_EACH_SAFE (evg, next, id_node, &table->eviction_groups_by_id) {
+ struct eviction_group *evg;
+ HMAP_FOR_EACH_SAFE (evg, id_node, &table->eviction_groups_by_id) {
eviction_group_destroy(table, evg);
}
hmap_destroy(&table->eviction_groups_by_id);