diff options
author | Nick Mathewson <nickm@torproject.org> | 2016-05-30 11:12:58 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2016-06-11 10:10:29 -0400 |
commit | 4f8086fb20e93c477f033f58da17aa31b9c29fd6 (patch) | |
tree | cc6d6fb5cc6d7852f82295aa92c87d7068df1271 /src/ext/ht.h | |
parent | 55b5e0076fbd22a78ef2297ccb3a81bf03c42924 (diff) | |
download | tor-4f8086fb20e93c477f033f58da17aa31b9c29fd6.tar.gz tor-4f8086fb20e93c477f033f58da17aa31b9c29fd6.zip |
Enable -Wnull-dereference (GCC >=6.1), and fix the easy cases
This warning, IIUC, means that the compiler doesn't like it when it
sees a NULL check _after_ we've already dereferenced the
variable. In such cases, it considers itself free to eliminate the
NULL check.
There are a couple of tricky cases:
One was the case related to the fact that tor_addr_to_in6() can
return NULL if it gets a non-AF_INET6 address. The fix was to
create a variant which asserts on the address type, and never
returns NULL.
Diffstat (limited to 'src/ext/ht.h')
-rw-r--r-- | src/ext/ht.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/ext/ht.h b/src/ext/ht.h index 28d1fe49d5..1b6cbe6632 100644 --- a/src/ext/ht.h +++ b/src/ext/ht.h @@ -203,6 +203,7 @@ ht_string_hash(const char *s) name##_HT_GROW(head, head->hth_n_entries+1); \ HT_SET_HASH_(elm, field, hashfn); \ p = name##_HT_FIND_P_(head, elm); \ + HT_ASSERT_(p != NULL); /* this holds because we called HT_GROW */ \ r = *p; \ *p = elm; \ if (r && (r!=elm)) { \ @@ -470,6 +471,7 @@ ht_string_hash(const char *s) name##_HT_GROW(var##_head_, var##_head_->hth_n_entries+1); \ HT_SET_HASH_((elm), field, hashfn); \ var = name##_HT_FIND_P_(var##_head_, (elm)); \ + HT_ASSERT_(var); /* Holds because we called HT_GROW */ \ if (*var) { \ y; \ } else { \ |