From 73d52cdb3359a238fc717f9540d0075bc8568904 Mon Sep 17 00:00:00 2001 From: iphydf Date: Thu, 10 Feb 2022 17:20:29 +0000 Subject: [PATCH] chore: Disable non-null attributes by default. We enable them on CI, but a default build will compile without them so a default build doesn't end up with lots of warnings (which we also disable on CI). --- .circleci/cmake-ubsan | 4 ++++ toxcore/attributes.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.circleci/cmake-ubsan b/.circleci/cmake-ubsan index 81954ac7..45e64d87 100755 --- a/.circleci/cmake-ubsan +++ b/.circleci/cmake-ubsan @@ -11,6 +11,10 @@ add_flag -fno-omit-frame-pointer add_flag -fno-sanitize-recover=all add_flag -fsanitize=undefined,nullability,local-bounds,float-divide-by-zero,integer add_flag -fno-sanitize=implicit-conversion,unsigned-integer-overflow +# Enable extra checks. We only do this on ubsan because it shows useful error +# messages for the kind of bugs this catches (mostly incorrect nullability +# annotations). Other builds will segfault, ubsan will show a stack trace. +add_flag -D_DEBUG cmake -B_build -H. -GNinja \ -DCMAKE_C_FLAGS="$C_FLAGS" \ -DCMAKE_CXX_FLAGS="$CXX_FLAGS" \ diff --git a/toxcore/attributes.h b/toxcore/attributes.h index ba56c6a3..3d3aeda0 100644 --- a/toxcore/attributes.h +++ b/toxcore/attributes.h @@ -18,7 +18,7 @@ #define GNU_PRINTF(f, a) #endif -#if defined(__GNUC__) && !defined(NDEBUG) +#if defined(__GNUC__) && defined(_DEBUG) #define non_null(...) __attribute__((__nonnull__(__VA_ARGS__))) #else #define non_null(...)