summaryrefslogtreecommitdiff
path: root/ofproto
diff options
context:
space:
mode:
authorAdrian Moreno <amorenoz@redhat.com>2022-03-23 12:56:14 +0100
committerIlya Maximets <i.maximets@ovn.org>2022-03-30 16:59:02 +0200
commite9bf5bffb020e3dca4104118e15c69242bc12e33 (patch)
tree01e35216faf311d3313c6f20464dc884c2dc1f81 /ofproto
parentd4566085edf50033087652f35f92b9b77cbec70f (diff)
downloadopenvswitch-e9bf5bffb020e3dca4104118e15c69242bc12e33.tar.gz
list: use short version of safe loops if possible.
Using the 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. 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/connmgr.c8
-rw-r--r--ofproto/ofproto-dpif-ipfix.c4
-rw-r--r--ofproto/ofproto-dpif-trace.c4
-rw-r--r--ofproto/ofproto-dpif-xlate.c4
-rw-r--r--ofproto/ofproto-dpif.c24
5 files changed, 21 insertions, 23 deletions
diff --git a/ofproto/connmgr.c b/ofproto/connmgr.c
index fa8f6cd0e..5666d7283 100644
--- a/ofproto/connmgr.c
+++ b/ofproto/connmgr.c
@@ -351,8 +351,8 @@ connmgr_run(struct connmgr *mgr,
}
}
- struct ofconn *ofconn, *next_ofconn;
- LIST_FOR_EACH_SAFE (ofconn, next_ofconn, connmgr_node, &mgr->conns) {
+ struct ofconn *ofconn;
+ LIST_FOR_EACH_SAFE (ofconn, connmgr_node, &mgr->conns) {
ofconn_run(ofconn, handle_openflow);
}
ofmonitor_run(mgr);
@@ -1953,8 +1953,8 @@ static void
ofservice_close_all(struct ofservice *ofservice)
OVS_REQUIRES(ofproto_mutex)
{
- struct ofconn *ofconn, *next;
- LIST_FOR_EACH_SAFE (ofconn, next, ofservice_node, &ofservice->conns) {
+ struct ofconn *ofconn;
+ LIST_FOR_EACH_SAFE (ofconn, ofservice_node, &ofservice->conns) {
ofconn_destroy(ofconn);
}
}
diff --git a/ofproto/ofproto-dpif-ipfix.c b/ofproto/ofproto-dpif-ipfix.c
index 9280e008e..ff4b6339a 100644
--- a/ofproto/ofproto-dpif-ipfix.c
+++ b/ofproto/ofproto-dpif-ipfix.c
@@ -2799,7 +2799,7 @@ dpif_ipfix_cache_expire(struct dpif_ipfix_exporter *exporter,
bool forced_end, const uint64_t export_time_usec,
const uint32_t export_time_sec)
{
- struct ipfix_flow_cache_entry *entry, *next_entry;
+ struct ipfix_flow_cache_entry *entry;
uint64_t max_flow_start_timestamp_usec;
bool template_msg_sent = false;
enum ipfix_flow_end_reason flow_end_reason;
@@ -2811,7 +2811,7 @@ dpif_ipfix_cache_expire(struct dpif_ipfix_exporter *exporter,
max_flow_start_timestamp_usec = export_time_usec -
1000000LL * exporter->cache_active_timeout;
- LIST_FOR_EACH_SAFE (entry, next_entry, cache_flow_start_timestamp_list_node,
+ LIST_FOR_EACH_SAFE (entry, cache_flow_start_timestamp_list_node,
&exporter->cache_flow_start_timestamp_list) {
if (forced_end) {
flow_end_reason = FORCED_END;
diff --git a/ofproto/ofproto-dpif-trace.c b/ofproto/ofproto-dpif-trace.c
index 78a54c715..109940ad2 100644
--- a/ofproto/ofproto-dpif-trace.c
+++ b/ofproto/ofproto-dpif-trace.c
@@ -65,8 +65,8 @@ static void
oftrace_node_list_destroy(struct ovs_list *nodes)
{
if (nodes) {
- struct oftrace_node *node, *next;
- LIST_FOR_EACH_SAFE (node, next, node, nodes) {
+ struct oftrace_node *node;
+ LIST_FOR_EACH_SAFE (node, node, nodes) {
ovs_list_remove(&node->node);
oftrace_node_destroy(node);
}
diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index cc9c1c628..922e02e97 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -1282,7 +1282,7 @@ xlate_ofproto_set(struct ofproto_dpif *ofproto, const char *name,
static void
xlate_xbridge_remove(struct xlate_cfg *xcfg, struct xbridge *xbridge)
{
- struct xbundle *xbundle, *next_xbundle;
+ struct xbundle *xbundle;
struct xport *xport, *next_xport;
if (!xbridge) {
@@ -1293,7 +1293,7 @@ xlate_xbridge_remove(struct xlate_cfg *xcfg, struct xbridge *xbridge)
xlate_xport_remove(xcfg, xport);
}
- LIST_FOR_EACH_SAFE (xbundle, next_xbundle, list_node, &xbridge->xbundles) {
+ LIST_FOR_EACH_SAFE (xbundle, list_node, &xbridge->xbundles) {
xlate_xbundle_remove(xcfg, xbundle);
}
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index a4c44052d..9d4d55afb 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -1936,7 +1936,7 @@ run(struct ofproto *ofproto_)
new_dump_seq = seq_read(udpif_dump_seq(ofproto->backer->udpif));
if (ofproto->dump_seq != new_dump_seq) {
- struct rule *rule, *next_rule;
+ struct rule *rule;
long long now = time_msec();
/* We know stats are relatively fresh, so now is a good time to do some
@@ -1946,7 +1946,7 @@ run(struct ofproto *ofproto_)
/* Expire OpenFlow flows whose idle_timeout or hard_timeout
* has passed. */
ovs_mutex_lock(&ofproto_mutex);
- LIST_FOR_EACH_SAFE (rule, next_rule, expirable,
+ LIST_FOR_EACH_SAFE (rule, expirable,
&ofproto->up.expirable) {
rule_expire(rule_dpif_cast(rule), now);
}
@@ -3103,11 +3103,11 @@ bundle_flush_macs(struct ofbundle *bundle, bool all_ofprotos)
{
struct ofproto_dpif *ofproto = bundle->ofproto;
struct mac_learning *ml = ofproto->ml;
- struct mac_entry *mac, *next_mac;
+ struct mac_entry *mac;
ofproto->backer->need_revalidate = REV_RECONFIGURE;
ovs_rwlock_wrlock(&ml->rwlock);
- LIST_FOR_EACH_SAFE (mac, next_mac, lru_node, &ml->lrus) {
+ LIST_FOR_EACH_SAFE (mac, lru_node, &ml->lrus) {
if (mac_entry_get_port(ml, mac) == bundle) {
if (all_ofprotos) {
struct ofproto_dpif *o;
@@ -3138,13 +3138,13 @@ bundle_move(struct ofbundle *old, struct ofbundle *new)
{
struct ofproto_dpif *ofproto = old->ofproto;
struct mac_learning *ml = ofproto->ml;
- struct mac_entry *mac, *next_mac;
+ struct mac_entry *mac;
ovs_assert(new->ofproto == old->ofproto);
ofproto->backer->need_revalidate = REV_RECONFIGURE;
ovs_rwlock_wrlock(&ml->rwlock);
- LIST_FOR_EACH_SAFE (mac, next_mac, lru_node, &ml->lrus) {
+ LIST_FOR_EACH_SAFE (mac, lru_node, &ml->lrus) {
if (mac_entry_get_port(ml, mac) == old) {
mac_entry_set_port(ml, mac, new);
}
@@ -3241,7 +3241,7 @@ static void
bundle_destroy(struct ofbundle *bundle)
{
struct ofproto_dpif *ofproto;
- struct ofport_dpif *port, *next_port;
+ struct ofport_dpif *port;
if (!bundle) {
return;
@@ -3254,7 +3254,7 @@ bundle_destroy(struct ofbundle *bundle)
xlate_bundle_remove(bundle);
xlate_txn_commit();
- LIST_FOR_EACH_SAFE (port, next_port, bundle_node, &bundle->ports) {
+ LIST_FOR_EACH_SAFE (port, bundle_node, &bundle->ports) {
bundle_del_port(port);
}
@@ -3344,9 +3344,7 @@ bundle_set(struct ofproto *ofproto_, void *aux,
}
}
if (!ok || ovs_list_size(&bundle->ports) != s->n_members) {
- struct ofport_dpif *next_port;
-
- LIST_FOR_EACH_SAFE (port, next_port, bundle_node, &bundle->ports) {
+ LIST_FOR_EACH_SAFE (port, bundle_node, &bundle->ports) {
for (i = 0; i < s->n_members; i++) {
if (s->members[i] == port->up.ofp_port) {
goto found;
@@ -5551,9 +5549,9 @@ ct_zone_timeout_policy_sweep(struct dpif_backer *backer)
{
if (!ovs_list_is_empty(&backer->ct_tp_kill_list)
&& time_msec() >= timeout_policy_cleanup_timer) {
- struct ct_timeout_policy *ct_tp, *next;
+ struct ct_timeout_policy *ct_tp;
- LIST_FOR_EACH_SAFE (ct_tp, next, list_node, &backer->ct_tp_kill_list) {
+ LIST_FOR_EACH_SAFE (ct_tp, list_node, &backer->ct_tp_kill_list) {
if (!ct_dpif_del_timeout_policy(backer->dpif, ct_tp->tp_id)) {
ovs_list_remove(&ct_tp->list_node);
ct_timeout_policy_destroy(ct_tp, backer->tp_ids);