Whamcloud - gitweb
LU-2503 libcfs: Call lbug_with_loc() in LASSERT()
authorJohn L. Hammond <jhammond@tacc.utexas.edu>
Mon, 17 Dec 2012 23:07:27 +0000 (17:07 -0600)
committerOleg Drokin <green@whamcloud.com>
Tue, 8 Jan 2013 05:30:02 +0000 (00:30 -0500)
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 <jhammond@tacc.utexas.edu>
Change-Id: Iac267c7804b5e18f687f47b2eea585c655e7bb21
Reviewed-on: http://review.whamcloud.com/4844
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Keith Mannthey <keith.mannthey@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
libcfs/include/libcfs/libcfs_private.h
libcfs/libcfs/posix/posix-debug.c
libcfs/libcfs/tracefile.c

index 5c55887..4488cd6 100644 (file)
  *
  * requires -Wall. Unfortunately this rules out use of likely/unlikely.
  */
  *
  * 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 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 */
 
 #define LASSERT(cond) LASSERTF(cond, "\n")
 #endif /* !LASSERT_CHECKED */
index 0d16d26..89d3278 100644 (file)
@@ -214,13 +214,6 @@ libcfs_debug_vmsg2(struct libcfs_debug_msg_data *msgdata,
         return 0;
 }
 
         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
 /*
  * 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
index cdc218e..e785f84 100644 (file)
@@ -478,15 +478,6 @@ console:
 EXPORT_SYMBOL(libcfs_debug_vmsg2);
 
 void
 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)
 {
 cfs_trace_assertion_failed(const char *str,
                            struct libcfs_debug_msg_data *msgdata)
 {