Standardize assert

This commit is contained in:
Enrico Fraccaroli
2019-05-10 11:28:47 +02:00
parent 9af9701ddb
commit 614d3dfd62
3 changed files with 13 additions and 27 deletions
+1
View File
@@ -204,6 +204,7 @@ set(SOURCE_FILES
src/kernel/sys.c
src/libc/assert.c
src/libc/ctype.c
src/libc/stdio.c
src/libc/string.c
+2 -12
View File
@@ -15,18 +15,8 @@
/// @param file The file where the assertion is located.
/// @param line The line inside the file.
/// @param function The function where the assertion is.
static void __assert_fail(const char *assertion, const char *file,
unsigned int line, const char *function)
{
char message[1024];
sprintf(message,
"FILE: %s\n"
"LINE: %d\n"
"FUNC: %s\n\n"
"Assertion `%s` failed.\n",
file, line, (function ? function : "NO_FUN"), assertion);
kernel_panic(message);
}
void __assert_fail(const char *assertion, const char *file, unsigned int line,
const char *function);
/// @brief Assert function.
#define assert(expression) \
+10 -15
View File
@@ -8,20 +8,15 @@
#include "stdio.h"
#include "panic.h"
void __assert_fail(const char *assertion,
const char *file,
unsigned int line,
const char *function)
void __assert_fail(const char *assertion, const char *file, unsigned int line,
const char *function)
{
char message[1024];
sprintf(message,
"FILE: %s\n"
"LINE: %d\n"
"FUNC: %s\n\n"
"Assertion `%s` failed.\n",
file,
line,
(function ? function : "NO_FUN"),
assertion);
kernel_panic(message);
char message[1024];
sprintf(message,
"FILE: %s\n"
"LINE: %d\n"
"FUNC: %s\n\n"
"Assertion `%s` failed.\n",
file, line, (function ? function : "NO_FUN"), assertion);
kernel_panic(message);
}