The existing dual-loop setup is unnecessary as the outer loop only skips to the first non-zero value and then exits once the inner loop completes. Zero values in the inner loop have no affect on its logic.
Signed-off-by: Simon Horman <[email protected]> --- v2 Initialise bucket Compile tested only --- ofproto/ofproto-dpif.c | 15 ++++++--------- 1 files changed, 6 insertions(+), 9 deletions(-) diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index c062ec3..97109a7 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -1864,7 +1864,7 @@ facet_max_idle(const struct ofproto_dpif *ofproto) enum { N_BUCKETS = 5000 / BUCKET_WIDTH }; int buckets[N_BUCKETS] = { 0 }; struct facet *facet; - int total, bucket; + int total, bucket = 0; long long int now; int i; @@ -1884,14 +1884,11 @@ facet_max_idle(const struct ofproto_dpif *ofproto) } /* Find the first bucket whose flows should be expired. */ - for (bucket = 0; bucket < N_BUCKETS; bucket++) { - if (buckets[bucket]) { - int subtotal = 0; - do { - subtotal += buckets[bucket++]; - } while (bucket < N_BUCKETS && subtotal < MAX(1000, total / 100)); - break; - } + { + int subtotal = 0; + do { + subtotal += buckets[bucket++]; + } while (bucket < N_BUCKETS && subtotal < MAX(1000, total / 100)); } if (VLOG_IS_DBG_ENABLED()) { -- 1.7.5.4 _______________________________________________ dev mailing list [email protected] http://openvswitch.org/mailman/listinfo/dev
