From f1685b42bb059af99c31fd5e5b8c68a41361a1d0 Mon Sep 17 00:00:00 2001 From: "John L. Hammond" Date: Wed, 5 Mar 2014 16:06:55 -0600 Subject: [PATCH] LU-4655 libcfs: properly (un)define CDEBUG_ENTRY_EXIT 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 Change-Id: Ia016b4ddd45f8c39704a84908665757aa17bd3d2 Reviewed-on: http://review.whamcloud.com/9517 Tested-by: Jenkins Reviewed-by: Dmitry Eremin Tested-by: Maloo Reviewed-by: Yang Sheng Reviewed-by: Oleg Drokin --- libcfs/autoconf/lustre-libcfs.m4 | 8 ++------ libcfs/include/libcfs/libcfs_debug.h | 36 ++++++++++++++++++++---------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/libcfs/autoconf/lustre-libcfs.m4 b/libcfs/autoconf/lustre-libcfs.m4 index 840bff7..cb86497 100644 --- a/libcfs/autoconf/lustre-libcfs.m4 +++ b/libcfs/autoconf/lustre-libcfs.m4 @@ -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]) diff --git a/libcfs/include/libcfs/libcfs_debug.h b/libcfs/include/libcfs/libcfs_debug.h index 204dfe0..1ea5713 100644 --- a/libcfs/include/libcfs/libcfs_debug.h +++ b/libcfs/include/libcfs/libcfs_debug.h @@ -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) -- 1.8.3.1