From 08a50d8cfe51c180c0efc2a1de2e57bdc09136d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20O=2E=20Sel=C3=A5sdal?= Date: Tue, 8 Oct 2013 17:39:44 +0200 Subject: [PATCH] fix UC_ASSERT writing to wrong fd, and unterminated if log more in UC_NOTREACHED --- include/ucore/utils.h | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/include/ucore/utils.h b/include/ucore/utils.h index 7253f04..5f8b0af 100644 --- a/include/ucore/utils.h +++ b/include/ucore/utils.h @@ -84,19 +84,26 @@ const typeof( ((const type *)0)->member ) *__mptr = (ptr); \ /** * assert() that is not affected by NDEBUG define */ -#define UC_ASSERT(expr) do {\ -if (!(expr) ) {\ - fprintf(stderr,\ - "UC_ASSERT failed '%s' %s:%d\n", UC_STRINGIFY(expr), __FILE__, __LINE__);\ - uc_backtrace_fd(3);\ - abort();\ +#define UC_ASSERT(expr)\ + do {\ + if (!(expr) ) {\ + fprintf(stderr,\ + "UC_ASSERT failed '%s' %s:%d\n", UC_STRINGIFY(expr), __FILE__, __LINE__);\ + uc_backtrace_fd(2);\ + abort();\ + }\ } while (0) /** * Macro for asserting code that should not be reached, * terminates the program if executed */ -#define UC_NOT_REACED() abort() +#define UC_NOT_REACED()\ +do {\ + fprintf(stderr, "UC_NOT_REACED at %s:%d\n", __FILE__, __LINE__);\ + uc_backtrace_fd(2);\ + abort();\ +while (0) /** * Round up X / y