summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2021-07-12 21:37:31 +0100
committerLinus Groh <mail@linusgroh.de>2021-07-12 22:33:28 +0100
commit15d5c629158fd598d162f5acba26ffee7a923ff8 (patch)
treeda173914ca46d378a0b0ba559b546942f6cc241c /Userland
parent0c7a319e6ba208bf91df298bdb8ba2843491a590 (diff)
downloadserenity-15d5c629158fd598d162f5acba26ffee7a923ff8.zip
LibC: Replace use of do/while in assert() with the ternary operator
It's a single expression, no do/while needed. This makes assert() work with the comma operator (assert(foo), assert(bar), assert(baz)). Found because exactly this is being used somewhere in the guts of LLVM.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibC/assert.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/Userland/Libraries/LibC/assert.h b/Userland/Libraries/LibC/assert.h
index b2dfdf6606..a05f939735 100644
--- a/Userland/Libraries/LibC/assert.h
+++ b/Userland/Libraries/LibC/assert.h
@@ -14,11 +14,11 @@ __BEGIN_DECLS
__attribute__((noreturn)) void __assertion_failed(const char* msg);
# define __stringify_helper(x) # x
# define __stringify(x) __stringify_helper(x)
-# define assert(expr) \
- do { \
- if (__builtin_expect(!(expr), 0)) \
- __assertion_failed(#expr "\n" __FILE__ ":" __stringify(__LINE__)); \
- } while (0)
+# define assert(expr) \
+ (__builtin_expect(!(expr), 0) \
+ ? __assertion_failed(#expr "\n" __FILE__ ":" __stringify(__LINE__)) \
+ : void(0))
+
#else
# define assert(expr) ((void)(0))
# define VERIFY_NOT_REACHED() _abort()