summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2024-12-16 11:52:12 -0500
committerTavian Barnes <tavianator@tavianator.com>2024-12-16 11:52:12 -0500
commitce378308af700657d9cba841939b2385b21accaa (patch)
tree1a9aa8d969ff0d3ac01821f40780d48d5c700120 /src
parent2c85bebb76627f6db99cb101d43bb26720f33854 (diff)
downloadbfs-ce378308af700657d9cba841939b2385b21accaa.tar.xz
sanity: Get rid of sanitize_ignore()
It's probably nicer to avoid evaluating expensive arguments when not sanitizing, rather than relying on the optimizer to clean them up.
Diffstat (limited to 'src')
-rw-r--r--src/alloc.c4
-rw-r--r--src/sanity.h13
2 files changed, 6 insertions, 11 deletions
diff --git a/src/alloc.c b/src/alloc.c
index ef9f6ab..9ab9983 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -317,8 +317,8 @@ void *varena_realloc(struct varena *varena, void *ptr, size_t old_count, size_t
return NULL;
}
- size_t new_exact_size = varena_exact_size(varena, new_count);
- size_t old_exact_size = varena_exact_size(varena, old_count);
+ _maybe_unused size_t new_exact_size = varena_exact_size(varena, new_count);
+ _maybe_unused size_t old_exact_size = varena_exact_size(varena, old_count);
if (new_arena == old_arena) {
if (new_count < old_count) {
diff --git a/src/sanity.h b/src/sanity.h
index 3f6020b..89d0e4f 100644
--- a/src/sanity.h
+++ b/src/sanity.h
@@ -20,11 +20,6 @@
#define SANITIZE_CALL__(macro, ptr, size, ...) \
macro(ptr, size)
-/**
- * Squelch unused variable warnings when not sanitizing.
- */
-#define sanitize_ignore(ptr, size) ((void)(ptr), (void)(size))
-
#if __SANITIZE_ADDRESS__
# include <sanitizer/asan_interface.h>
@@ -43,8 +38,8 @@
#define sanitize_free(...) SANITIZE_CALL(__asan_poison_memory_region, __VA_ARGS__)
#else
-# define sanitize_alloc(...) SANITIZE_CALL(sanitize_ignore, __VA_ARGS__)
-# define sanitize_free(...) SANITIZE_CALL(sanitize_ignore, __VA_ARGS__)
+# define sanitize_alloc(...) ((void)0)
+# define sanitize_free(...) ((void)0)
#endif
#if __SANITIZE_MEMORY__
@@ -65,8 +60,8 @@
#define sanitize_uninit(...) SANITIZE_CALL(__msan_allocated_memory, __VA_ARGS__)
#else
-# define sanitize_init(...) SANITIZE_CALL(sanitize_ignore, __VA_ARGS__)
-# define sanitize_uninit(...) SANITIZE_CALL(sanitize_ignore, __VA_ARGS__)
+# define sanitize_init(...) ((void)0)
+# define sanitize_uninit(...) ((void)0)
#endif
/**