From: Sebastian Hahn Date: Tue, 26 Apr 2011 00:20:29 +0000 (+0200) Subject: Add an assert to un-confuse clang's analyzer X-Git-Tag: tor-0.2.2.26-beta~14^2~3^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=58a16a4d6f47728e029cc8380604bda262a40d30;p=thirdparty%2Ftor.git Add an assert to un-confuse clang's analyzer The analyzer assumed that bootstrap_percent could be less than 0 when we call control_event_bootstrap_problem(), which would mean we're calling log_fn() with undefined values. The assert makes it clear this can't happen. --- diff --git a/src/or/control.c b/src/or/control.c index 28780d2989..926a465203 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -3931,6 +3931,9 @@ control_event_bootstrap_problem(const char *warn, int reason) char buf[BOOTSTRAP_MSG_LEN]; const char *recommendation = "ignore"; + /* bootstrap_percent must not be in "undefined" state here. */ + tor_assert(status >= 0); + if (bootstrap_percent == 100) return; /* already bootstrapped; nothing to be done here. */