[hackers] [scc] [libc] Don't call to __assert always || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Fri, 17 Feb 2017 11:24:06 +0100 (CET)

commit 22e17d14116ca2b13ea849f2f568c417d8143888
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Fri Feb 17 11:23:09 2017 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Fri Feb 17 11:23:09 2017 +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

diff --git a/libc/include/assert.h b/libc/include/assert.h
index 7654531..dd7764b 100644
--- a/libc/include/assert.h
+++ b/libc/include/assert.h
_AT_@ -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
index 0a6aa93..25c10a4 100644
--- a/libc/src/assert.c
+++ b/libc/src/assert.c
_AT_@ -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();
 }
Received on Fri Feb 17 2017 - 11:24:06 CET

This archive was generated by hypermail 2.3.0 : Fri Feb 17 2017 - 11:36:14 CET