Skip to content

Commit

Permalink
Consolidate __assert_failed into one implementation
Browse files Browse the repository at this point in the history
We had two implementations of __assert_failed which were almost identical,
combine them into one.

Signed-off-by: Alex Kiernan <[email protected]>
  • Loading branch information
akiernan authored and trini committed Apr 28, 2018
1 parent 4f1eed7 commit e21c03b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
8 changes: 8 additions & 0 deletions lib/panic.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,11 @@ void panic(const char *fmt, ...)
#endif
panic_finish();
}

void __assert_fail(const char *assertion, const char *file, unsigned int line,
const char *function)
{
/* This will not return */
panic("%s:%u: %s: Assertion `%s' failed.", file, line, function,
assertion);
}
9 changes: 0 additions & 9 deletions lib/tiny-printf.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,12 +383,3 @@ int snprintf(char *buf, size_t size, const char *fmt, ...)

return ret;
}

void __assert_fail(const char *assertion, const char *file, unsigned line,
const char *function)
{
/* This will not return */
printf("%s:%u: %s: Assertion `%s' failed.", file, line, function,
assertion);
hang();
}
8 changes: 0 additions & 8 deletions lib/vsprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -827,14 +827,6 @@ int vprintf(const char *fmt, va_list args)
}
#endif

void __assert_fail(const char *assertion, const char *file, unsigned line,
const char *function)
{
/* This will not return */
panic("%s:%u: %s: Assertion `%s' failed.", file, line, function,
assertion);
}

char *simple_itoa(ulong i)
{
/* 21 digits plus null terminator, good for 64-bit or smaller ints */
Expand Down

0 comments on commit e21c03b

Please sign in to comment.