diff options
author | teor <teor2345@gmail.com> | 2014-09-29 10:08:37 +1000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-09-28 20:51:23 -0400 |
commit | ff8fe38a2fac97d34bba4d46edabb4dd1bbe6d90 (patch) | |
tree | 78e3a12160d7455de69adb257aed0bdc281f3f72 | |
parent | 5190ec0bc4c22d7bab756e21db6e357ba07379c4 (diff) | |
download | tor-ff8fe38a2fac97d34bba4d46edabb4dd1bbe6d90.tar.gz tor-ff8fe38a2fac97d34bba4d46edabb4dd1bbe6d90.zip |
Stop spurious clang shallow analysis null pointer errors
Avoid 4 null pointer errors under clang shallow analysis (the default when
building under Xcode) by using tor_assert() to prove that the pointers
aren't null. Resolves issue 13284 via minor code refactoring.
-rw-r--r-- | changes/issue13284-spurious-clang-shallow-analyze-errors | 3 | ||||
-rw-r--r-- | src/or/dirserv.c | 2 | ||||
-rw-r--r-- | src/or/dirvote.c | 2 | ||||
-rw-r--r-- | src/or/routerlist.c | 2 |
4 files changed, 9 insertions, 0 deletions
diff --git a/changes/issue13284-spurious-clang-shallow-analyze-errors b/changes/issue13284-spurious-clang-shallow-analyze-errors new file mode 100644 index 0000000000..c08fa1f1b0 --- /dev/null +++ b/changes/issue13284-spurious-clang-shallow-analyze-errors @@ -0,0 +1,3 @@ + o Minor bugfixes: + - Avoid 4 null pointer errors under clang shallow analysis by using + tor_assert() to prove that the pointers aren't null. Fixes bug 13284. diff --git a/src/or/dirserv.c b/src/or/dirserv.c index 91314405df..374cfa6f40 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -1395,6 +1395,8 @@ dirserv_compute_performance_thresholds(routerlist_t *rl, routerinfo_t *ri = node->ri; const char *id = node->identity; uint32_t bw_kb; + /* resolve spurious clang shallow analysis null pointer errors */ + tor_assert(ri); node->is_exit = (!router_exit_policy_rejects_all(ri) && exit_policy_is_general_exit(ri->exit_policy)); uptimes[n_active] = (uint32_t)real_uptime(ri, now); diff --git a/src/or/dirvote.c b/src/or/dirvote.c index 9ad92ca116..8a0fdf62fc 100644 --- a/src/or/dirvote.c +++ b/src/or/dirvote.c @@ -647,6 +647,8 @@ dirvote_compute_params(smartlist_t *votes, int method, int total_authorities) next_param = NULL; else next_param = smartlist_get(param_list, param_sl_idx+1); + /* resolve spurious clang shallow analysis null pointer errors */ + tor_assert(param); if (!next_param || strncmp(next_param, param, cur_param_len)) { /* We've reached the end of a series. */ /* Make sure enough authorities voted on this param, unless the diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 1faa05f06f..22489a4476 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -475,6 +475,8 @@ trusted_dirs_remove_old_certs(void) time_t cert_published; if (newest == cert) continue; + /* resolve spurious clang shallow analysis null pointer errors */ + tor_assert(cert); expired = now > cert->expires; cert_published = cert->cache_info.published_on; /* Store expired certs for 48 hours after a newer arrives; |