Whamcloud - gitweb
LU-4655 libcfs: properly (un)define CDEBUG_ENTRY_EXIT 17/9517/2
authorJohn L. Hammond <john.hammond@intel.com>
Wed, 5 Mar 2014 22:06:55 +0000 (16:06 -0600)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 26 Mar 2014 00:02:38 +0000 (00:02 +0000)
In lustre-libcfs.m4 we defined CDEBUG_ENTRY_EXIT to 1 or 0 according
to whether libcfs-trace was enabled. But in libcfs_debug.h we tested
CDEBUG_ENTRY_EXIT using #ifdef and enabled the trace macros
accrodingly. Fix this and use CDEBUG_ENTRY_EXIT to control GOTO()
tracing as well. The ability to properly disable these macros will
make some static analyses easier.

Signed-off-by: John L. Hammond <john.hammond@intel.com>
Change-Id: Ia016b4ddd45f8c39704a84908665757aa17bd3d2
Reviewed-on: http://review.whamcloud.com/9517
Tested-by: Jenkins
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Yang Sheng <yang.sheng@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
libcfs/autoconf/lustre-libcfs.m4
libcfs/include/libcfs/libcfs_debug.h

index 840bff7..cb86497 100644 (file)
@@ -12,9 +12,7 @@ AC_ARG_ENABLE([libcfs_cdebug],
        [],[enable_libcfs_cdebug='yes'])
 AC_MSG_RESULT([$enable_libcfs_cdebug])
 if test x$enable_libcfs_cdebug = xyes; then
-   AC_DEFINE(CDEBUG_ENABLED, 1, [enable libcfs CDEBUG, CWARN])
-else
-   AC_DEFINE(CDEBUG_ENABLED, 0, [disable libcfs CDEBUG, CWARN])
+       AC_DEFINE(CDEBUG_ENABLED, 1, [enable libcfs CDEBUG, CWARN])
 fi
 
 AC_MSG_CHECKING([whether to enable ENTRY/EXIT])
@@ -24,9 +22,7 @@ AC_ARG_ENABLE([libcfs_trace],
        [],[enable_libcfs_trace='yes'])
 AC_MSG_RESULT([$enable_libcfs_trace])
 if test x$enable_libcfs_trace = xyes; then
-   AC_DEFINE(CDEBUG_ENTRY_EXIT, 1, [enable libcfs ENTRY/EXIT])
-else
-   AC_DEFINE(CDEBUG_ENTRY_EXIT, 0, [disable libcfs ENTRY/EXIT])
+       AC_DEFINE(CDEBUG_ENTRY_EXIT, 1, [enable libcfs ENTRY/EXIT])
 fi
 
 AC_MSG_CHECKING([whether to enable LASSERT, LASSERTF])
index 204dfe0..1ea5713 100644 (file)
@@ -282,24 +282,22 @@ do {                                                                    \
 
 #define LCONSOLE_EMERG(format, ...) CDEBUG(D_CONSOLE | D_EMERG, format, ## __VA_ARGS__)
 
-#ifdef CDEBUG_ENABLED
+#ifdef CDEBUG_ENTRY_EXIT
 
-void libcfs_log_goto(struct libcfs_debug_msg_data *, const char *, long_ptr_t);
-#define GOTO(label, rc)                                                 \
-do {                                                                    \
-        if (cfs_cdebug_show(D_TRACE, DEBUG_SUBSYSTEM)) {                \
-                LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, D_TRACE, NULL);     \
-                libcfs_log_goto(&msgdata, #label, (long_ptr_t)(rc));    \
-        } else {                                                        \
-                (void)(rc);                                             \
-        }                                                               \
-        goto label;                                                     \
-} while (0)
-#else
-#define GOTO(label, rc) do { ((void)(rc)); goto label; } while (0)
-#endif
+void libcfs_log_goto(struct libcfs_debug_msg_data *goto_data,
+                    const char *label, long_ptr_t rc);
 
-#ifdef CDEBUG_ENTRY_EXIT
+# define GOTO(label, rc)                                               \
+do {                                                                   \
+       if (cfs_cdebug_show(D_TRACE, DEBUG_SUBSYSTEM)) {                \
+               LIBCFS_DEBUG_MSG_DATA_DECL(_goto_data, D_TRACE, NULL);  \
+               libcfs_log_goto(&_goto_data, #label, (long_ptr_t)(rc)); \
+       } else {                                                        \
+               (void)(rc);                                             \
+       }                                                               \
+                                                                       \
+       goto label;                                                     \
+} while (0)
 
 /*
  * if rc == NULL, we need to code as RETURN((void *)NULL), otherwise
@@ -364,6 +362,12 @@ do {                                                                    \
 } while(0)
 #else /* !CDEBUG_ENTRY_EXIT */
 
+# define GOTO(label, rc)                                               \
+       do {                                                            \
+               ((void)(rc));                                           \
+               goto label;                                             \
+       } while (0)
+
 #define RETURN(rc) return (rc)
 #define ENTRY                           do { } while (0)
 #define EXIT                            do { } while (0)