shithub: scc

Download patch

ref: a62afbe74e2be29ed8b697a4094c5778cddfa09e
parent: 41850b088910e270b84f3a68b16c305556fa61a1
author: Roberto E. Vargas Caballero <[email protected]>
date: Fri Feb 17 06:23:09 EST 2017

[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

--- 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
--- 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();
 }