summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-07-17 10:41:24 -0400
committerNick Mathewson <nickm@torproject.org>2012-07-17 10:41:24 -0400
commitefdf6c711810cfa951741071cb7b67c3a76f2651 (patch)
tree7190e964456734c891eb33c7f539ffd179c55075
parent7faf115dfffaf12cdae98eac71fc6811059c6657 (diff)
downloadtor-efdf6c711810cfa951741071cb7b67c3a76f2651.tar.gz
tor-efdf6c711810cfa951741071cb7b67c3a76f2651.zip
Fix the remaining instances of nexted SMARTLIST_FOREACH
-rw-r--r--changes/smartlist_foreach2
-rw-r--r--src/or/networkstatus.c8
-rw-r--r--src/or/rendservice.c8
3 files changed, 10 insertions, 8 deletions
diff --git a/changes/smartlist_foreach b/changes/smartlist_foreach
index d1e3505468..0a6c960427 100644
--- a/changes/smartlist_foreach
+++ b/changes/smartlist_foreach
@@ -2,3 +2,5 @@
- Do not allow the body of any SMARTLIST_FOREACH block to exceed
10 lines. Doing so in the past has led to hard-to-debug code.
The new style is to use the SMARTLIST_FOREACH_{BEGIN,END} pair.
+ - Do not allow SMARTLIST_FOREACH blocks to nest. Any nested block
+ ought to be using SMARTLIST_FOREACH_{BEGIN,END}.
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c
index 1979250c5b..fadaf90da4 100644
--- a/src/or/networkstatus.c
+++ b/src/or/networkstatus.c
@@ -128,12 +128,12 @@ networkstatus_reset_download_failures(void)
{
int i;
const smartlist_t *networkstatus_v2_list = networkstatus_get_v2_list();
- SMARTLIST_FOREACH(networkstatus_v2_list, networkstatus_v2_t *, ns,
- SMARTLIST_FOREACH(ns->entries, routerstatus_t *, rs,
- {
+ SMARTLIST_FOREACH_BEGIN(networkstatus_v2_list, networkstatus_v2_t *, ns) {
+ SMARTLIST_FOREACH_BEGIN(ns->entries, routerstatus_t *, rs) {
if (!router_get_by_descriptor_digest(rs->descriptor_digest))
rs->need_to_mirror = 1;
- }));;
+ } SMARTLIST_FOREACH_END(rs);
+ } SMARTLIST_FOREACH_END(ns);
for (i=0; i < N_CONSENSUS_FLAVORS; ++i)
download_status_reset(&consensus_dl_status[i]);
diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index 6a51874699..6af4778dfc 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -500,16 +500,16 @@ rend_config_services(const or_options_t *options, int validate_only)
/* Copy introduction points to new services. */
/* XXXX This is O(n^2), but it's only called on reconfigure, so it's
* probably ok? */
- SMARTLIST_FOREACH(rend_service_list, rend_service_t *, new, {
- SMARTLIST_FOREACH(old_service_list, rend_service_t *, old, {
+ SMARTLIST_FOREACH_BEGIN(rend_service_list, rend_service_t *, new) {
+ SMARTLIST_FOREACH_BEGIN(old_service_list, rend_service_t *, old) {
if (!strcmp(old->directory, new->directory)) {
smartlist_add_all(new->intro_nodes, old->intro_nodes);
smartlist_clear(old->intro_nodes);
smartlist_add(surviving_services, old);
break;
}
- });
- });
+ } SMARTLIST_FOREACH_END(old);
+ } SMARTLIST_FOREACH_END(new);
/* Close introduction circuits of services we don't serve anymore. */
/* XXXX it would be nicer if we had a nicer abstraction to use here,