commit 22e17d14116ca2b13ea849f2f568c417d8143888
parent dc40bafa82c336fa2c05d4fab11e5639a85ec3c6
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Fri, 17 Feb 2017 11:23:09 +0100
[libc] Don't call to __assert always
It is better to call to __assert only when there is a failed
assertion, because it is less disruptive with the program
Diffstat:
2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/libc/include/assert.h b/libc/include/assert.h
@@ -2,10 +2,10 @@
#ifndef _ASSERT_H
#define _ASSERT_H
-void __assert(int status, char *exp, char *file, long line);
+void __assert(char *exp, char *file, long line);
#ifndef NDEBUG
-# define assert(exp) __assert(exp, #exp, __FILE__, __LINE__)
+# define assert(exp) ((exp) ? (void) 0 : __assert(#exp, __FILE__, __LINE__))
#else
# define assert(exp) ((void)0)
#endif
diff --git a/libc/src/assert.c b/libc/src/assert.c
@@ -4,10 +4,8 @@
#include <stdlib.h>
#include <stdio.h>
-void __assert(int status, char *exp, char *file, long line)
+void __assert(char *exp, char *file, long line)
{
- if (status)
- return;
fprintf(stderr, "%s:%ld: assertion failed '%s'\n", file, line, exp);
abort();
}