summaryrefslogtreecommitdiff
path: root/libmisc
diff options
context:
space:
mode:
Diffstat (limited to 'libmisc')
-rw-r--r--libmisc/assert.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/libmisc/assert.c b/libmisc/assert.c
index 987fb4d..9b1a0bc 100644
--- a/libmisc/assert.c
+++ b/libmisc/assert.c
@@ -4,20 +4,28 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
-#include <stdio.h> /* for fprintf(), stderr */
-#include <stdlib.h> /* for abort() */
+#include <stdbool.h> /* for bool, true, false */
+#include <stdio.h> /* for printf() */
+#include <stdlib.h> /* for abort() */
#include <libmisc/assert.h>
#ifndef NDEBUG
+
+static bool in_fail = false;
+
__attribute__((__noreturn__)) void
__assert_msg_fail(const char *expr,
const char *file, unsigned int line, const char *func,
const char *msg) {
- fprintf(stderr, "error: %s:%u:%s(): assertion \"%s\" failed%s%s\n",
- file, line, func,
- expr,
- msg ? ": " : "", msg);
+ if (!in_fail) {
+ in_fail = true;
+ printf("error: %s:%u:%s(): assertion \"%s\" failed%s%s\n",
+ file, line, func,
+ expr,
+ msg ? ": " : "", msg);
+ }
abort();
}
+
#endif