[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r8821: Make "boolean !=" logic more obvious. (in tor/trunk: . src/or)
Author: nickm
Date: 2006-10-24 17:41:48 -0400 (Tue, 24 Oct 2006)
New Revision: 8821
Modified:
tor/trunk/
tor/trunk/src/or/dirserv.c
Log:
r9162@totoro: nickm | 2006-10-24 17:41:35 -0400
Make "boolean !=" logic more obvious.
Property changes on: tor/trunk
___________________________________________________________________
svk:merge ticket from /tor/trunk [r9162] on 96637b51-b116-0410-a10e-9941ebb49b64
Modified: tor/trunk/src/or/dirserv.c
===================================================================
--- tor/trunk/src/or/dirserv.c 2006-10-24 21:38:31 UTC (rev 8820)
+++ tor/trunk/src/or/dirserv.c 2006-10-24 21:41:48 UTC (rev 8821)
@@ -566,6 +566,13 @@
}
}
+
+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 @@
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;