From 2668b5ab52f1a004c4d4383c648d0184467b8a2f Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Mon, 17 Dec 2012 17:07:27 -0600 Subject: [PATCH] LU-2503 libcfs: Call lbug_with_loc() in LASSERT() LASSERT() declares a msgdata which can be passed to lbug_with_loc() instead of calling LBUG() thereby saving /millions/ of bytes. Also remove unused libcfs_assertion_failed(). Signed-off-by: John L. Hammond Change-Id: Iac267c7804b5e18f687f47b2eea585c655e7bb21 Reviewed-on: http://review.whamcloud.com/4844 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Keith Mannthey Reviewed-by: Andreas Dilger --- libcfs/include/libcfs/libcfs_private.h | 44 +++++++++++++++++----------------- libcfs/libcfs/posix/posix-debug.c | 7 ------ libcfs/libcfs/tracefile.c | 9 ------- 3 files changed, 22 insertions(+), 38 deletions(-) diff --git a/libcfs/include/libcfs/libcfs_private.h b/libcfs/include/libcfs/libcfs_private.h index 5c55887..4488cd6 100644 --- a/libcfs/include/libcfs/libcfs_private.h +++ b/libcfs/include/libcfs/libcfs_private.h @@ -71,33 +71,33 @@ * * requires -Wall. Unfortunately this rules out use of likely/unlikely. */ -#define LASSERTF(cond, fmt, ...) \ -do { \ - if (cond) \ - ; \ - else { \ - LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, D_EMERG, NULL); \ - libcfs_debug_msg(&msgdata, \ - "ASSERTION( %s ) failed: " fmt, #cond, \ - ## __VA_ARGS__); \ - LBUG(); \ - } \ -} while(0) +#define LASSERTF(cond, fmt, ...) \ +do { \ + if (cond) \ + ; \ + else { \ + LIBCFS_DEBUG_MSG_DATA_DECL(__msg_data, D_EMERG, NULL); \ + libcfs_debug_msg(&__msg_data, \ + "ASSERTION( %s ) failed: " fmt, #cond, \ + ## __VA_ARGS__); \ + lbug_with_loc(&__msg_data); \ + } \ +} while (0) #define LASSERT(cond) LASSERTF(cond, "\n") #else /* !LASSERT_CHECKED */ -#define LASSERTF(cond, fmt, ...) \ -do { \ - if (unlikely(!(cond))) { \ - LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, D_EMERG, NULL); \ - libcfs_debug_msg(&msgdata, \ - "ASSERTION( %s ) failed: " fmt, #cond, \ - ## __VA_ARGS__ ); \ - LBUG(); \ - } \ -} while(0) +#define LASSERTF(cond, fmt, ...) \ +do { \ + if (unlikely(!(cond))) { \ + LIBCFS_DEBUG_MSG_DATA_DECL(__msg_data, D_EMERG, NULL); \ + libcfs_debug_msg(&__msg_data, \ + "ASSERTION( %s ) failed: " fmt, #cond, \ + ## __VA_ARGS__); \ + lbug_with_loc(&__msg_data); \ + } \ +} while (0) #define LASSERT(cond) LASSERTF(cond, "\n") #endif /* !LASSERT_CHECKED */ diff --git a/libcfs/libcfs/posix/posix-debug.c b/libcfs/libcfs/posix/posix-debug.c index 0d16d26..89d3278 100644 --- a/libcfs/libcfs/posix/posix-debug.c +++ b/libcfs/libcfs/posix/posix-debug.c @@ -214,13 +214,6 @@ libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata, return 0; } -void -libcfs_assertion_failed(const char *expr, struct libcfs_debug_msg_data *msgdata) -{ - libcfs_debug_msg(msgdata, "ASSERTION(%s) failed\n", expr); - abort(); -} - /* * a helper function for RETURN(): the sole purpose is to save 8-16 bytes * on the stack - function calling RETURN() doesn't need to allocate two diff --git a/libcfs/libcfs/tracefile.c b/libcfs/libcfs/tracefile.c index cdc218e..e785f84 100644 --- a/libcfs/libcfs/tracefile.c +++ b/libcfs/libcfs/tracefile.c @@ -478,15 +478,6 @@ console: EXPORT_SYMBOL(libcfs_debug_vmsg2); void -libcfs_assertion_failed(const char *expr, struct libcfs_debug_msg_data *msgdata) -{ - libcfs_debug_msg(msgdata, "ASSERTION(%s) failed\n", expr); - /* cfs_enter_debugger(); */ - lbug_with_loc(msgdata); -} -EXPORT_SYMBOL(libcfs_assertion_failed); - -void cfs_trace_assertion_failed(const char *str, struct libcfs_debug_msg_data *msgdata) { -- 1.8.3.1