diff options
author | Nick Mathewson <nickm@torproject.org> | 2006-10-24 21:41:48 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2006-10-24 21:41:48 +0000 |
commit | 6b7d1c94da0f832ebff2e22f3ce324c655600f4b (patch) | |
tree | afdf713ac2176d1947eb56b530027ad16a6f961d | |
parent | a5bf6df14a7e8c5536a80d5ff914d2a42da9030d (diff) | |
download | tor-6b7d1c94da0f832ebff2e22f3ce324c655600f4b.tar tor-6b7d1c94da0f832ebff2e22f3ce324c655600f4b.tar.gz |
r9162@totoro: nickm | 2006-10-24 17:41:35 -0400
Make "boolean !=" logic more obvious.
svn:r8821
-rw-r--r-- | src/or/dirserv.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/or/dirserv.c b/src/or/dirserv.c index 543712dcc..99d57bf6d 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -566,6 +566,13 @@ dirserv_add_descriptor(const char *desc, const char **msg) } } + +static INLINE int +bool_neq(int a, int b) +{ + return (a && !b) || (!a && b); +} + /** Remove all descriptors whose nicknames or fingerprints no longer * are allowed by our fingerprint list. (Descriptors that used to be * good can become bad when we reload the fingerprint list.) @@ -587,20 +594,20 @@ directory_remove_invalid(void) routerlist_remove(rl, ent, i--, 0); changed = 1; } - if (!(r & FP_NAMED) != !ent->is_named) { + if (bool_neq((r & FP_NAMED), ent->is_named)) { log_info(LD_DIRSERV, "Router '%s' is now %snamed.", ent->nickname, (r&FP_NAMED)?"":"un"); ent->is_named = (r&FP_NAMED)?1:0; changed = 1; } - if (!(r & FP_INVALID) != !!ent->is_valid) { + if (bool_neq((r & FP_INVALID), !ent->is_valid)) { log_info(LD_DIRSERV, "Router '%s' is now %svalid.", ent->nickname, (r&FP_INVALID) ? "in" : ""); ent->is_valid = (r&FP_INVALID)?0:1; changed = 1; } - if (!(r & FP_BADEXIT) != !ent->is_bad_exit) { + if (bool_neq((r & FP_BADEXIT), ent->is_bad_exit)) { log_info(LD_DIRSERV, "Router '%s' is now a %s exit", ent->nickname, (r & FP_BADEXIT) ? "bad" : "good"); ent->is_bad_exit = (r&FP_BADEXIT) ? 1: 0; |