From 5dbdfff733b4833397feba64047dabac9bb36531 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Tue, 20 Apr 2010 13:58:24 -0700 Subject: [PATCH] in-band: Avoid magic number in refresh_remotes(). The initial value of min_refresh() can only matter if there are no remotes, in which case there is nothing to refresh anyhow. So avoid the magic number "10" as the initial minimum, since it has no real significance. Suggested-by: Justin Pettit --- ofproto/in-band.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ofproto/in-band.c b/ofproto/in-band.c index 12ae8f34..d918d713 100644 --- a/ofproto/in-band.c +++ b/ofproto/in-band.c @@ -313,24 +313,23 @@ refresh_remotes(struct in_band *ib) { struct in_band_remote *r; bool any_changes; - int min_refresh; if (time_now() < ib->next_remote_refresh) { return false; } any_changes = false; - min_refresh = 10; + ib->next_remote_refresh = TIME_MAX; for (r = ib->remotes; r < &ib->remotes[ib->n_remotes]; r++) { uint8_t old_remote_mac[ETH_ADDR_LEN]; - int refresh_interval; + time_t next_refresh; /* Save old MAC. */ memcpy(old_remote_mac, r->remote_mac, ETH_ADDR_LEN); /* Refresh remote information. */ - refresh_interval = refresh_remote(ib, r); - min_refresh = MIN(min_refresh, refresh_interval); + next_refresh = refresh_remote(ib, r) + time_now(); + ib->next_remote_refresh = MIN(ib->next_remote_refresh, next_refresh); /* If the MAC changed, log the changes. */ if (!eth_addr_equals(r->remote_mac, old_remote_mac)) { @@ -345,7 +344,6 @@ refresh_remotes(struct in_band *ib) } } } - ib->next_remote_refresh = time_now() + min_refresh; return any_changes; } -- 2.30.2