aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2026-05-15 14:13:11 +1000
committerStefano Brivio <sbrivio@redhat.com>2026-05-16 17:04:11 +0200
commite51494552b784861b58f9546a25dfd74b8c09de9 (patch)
tree6961f2ad61765c3a22c3cf35376aecffda8ebd77
parentfd4b6378006e7398a3d965e4818b62ff50ff04ce (diff)
downloadpasst-e51494552b784861b58f9546a25dfd74b8c09de9.tar
passt-e51494552b784861b58f9546a25dfd74b8c09de9.tar.gz
passt-e51494552b784861b58f9546a25dfd74b8c09de9.tar.bz2
passt-e51494552b784861b58f9546a25dfd74b8c09de9.tar.lz
passt-e51494552b784861b58f9546a25dfd74b8c09de9.tar.xz
passt-e51494552b784861b58f9546a25dfd74b8c09de9.tar.zst
passt-e51494552b784861b58f9546a25dfd74b8c09de9.zip
Fix build with -DNDEBUG
Since bc872d91765d, our assert() statements are omitted if we compile with -DNDEBUG, like the standard library assert(3). Unfortunately a trivial but embarrassing mistake in that patch means that instead of never aborting in this case, assert_with_msg() *always* aborts, breaking pretty much everything. There's also a missing #include that breaks the build with -DNDEBUG on at least some library versions. Reported-by: Jan Palus <jpalus@fastmail.com> Fixes: bc872d91765d ("treewide: Spell ASSERT() as assert()") Signed-off-by: David Gibson <david@gibson.dropbear.id.au> [sbrivio: Explicitly avoid evaluation of expr in assert_with_msg on NDEBUG as suggested by Jan] Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r--util.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/util.h b/util.h
index 70aadeb..a9dcc04 100644
--- a/util.h
+++ b/util.h
@@ -6,6 +6,7 @@
#ifndef UTIL_H
#define UTIL_H
+#include <assert.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdbool.h>
@@ -50,7 +51,7 @@ void abort_with_msg(const char *fmt, ...)
*/
#ifndef NDEBUG
#define assert_with_msg(expr, ...) \
- ((expr) ? (void)0 : abort_with_msg(__VA_ARGS__))
+ (1 ? (void)0 : ((void)(expr), abort_with_msg(__VA_ARGS__)))
/* The standard library assert() hits our seccomp filter and dies before it can
* actually print a message. So, replace it with our own version.
*/
@@ -60,7 +61,7 @@ void abort_with_msg(const char *fmt, ...)
__func__, __FILE__, __LINE__, STRINGIFY(expr))
#else
#define assert_with_msg(expr, ...) \
- ((void)(expr), 0 ? (void)0 : abort_with_msg(__VA_ARGS__))
+ ((void)(expr), 1 ? (void)0 : abort_with_msg(__VA_ARGS__))
#endif
#ifdef P_tmpdir