From 4f8086fb20e93c477f033f58da17aa31b9c29fd6 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 30 May 2016 11:12:58 -0400 Subject: 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. --- src/test/test_bt_cl.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/test') diff --git a/src/test/test_bt_cl.c b/src/test/test_bt_cl.c index 2f5e50fbf5..ec03cedd0a 100644 --- a/src/test/test_bt_cl.c +++ b/src/test/test_bt_cl.c @@ -28,6 +28,9 @@ int a_tangled_web(int x) NOINLINE; int we_weave(int x) NOINLINE; static void abort_handler(int s) NORETURN; +#if GCC_VERSION >= 601 +DISABLE_GCC_WARNING(null-dereference) +#endif int crash(int x) { @@ -47,6 +50,9 @@ crash(int x) crashtype *= x; return crashtype; } +#if GCC_VERSION >= 601 +ENABLE_GCC_WARNING(null-dereference) +#endif int oh_what(int x) -- cgit v1.2.3-54-g00ecf