From 0a4308c2d82c2f5d3089f57b2e8af977682e91c5 Mon Sep 17 00:00:00 2001 From: nikita <nikita> Date: Fri, 8 Aug 2008 13:42:15 +0000 Subject: [PATCH] cdebug: separate mask and subsystem check into cdebug_show() function so that new logging functions can be defined outside of libcfs. --- libcfs/include/libcfs/libcfs_debug.h | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/libcfs/include/libcfs/libcfs_debug.h b/libcfs/include/libcfs/libcfs_debug.h index bfb1cb7862..49d819ece4 100644 --- a/libcfs/include/libcfs/libcfs_debug.h +++ b/libcfs/include/libcfs/libcfs_debug.h @@ -169,13 +169,21 @@ typedef struct { #if defined(__KERNEL__) || (defined(__arch_lib__) && !defined(LUSTRE_UTILS)) #ifdef CDEBUG_ENABLED + +/** + * Filters out logging messages based on mask and subsystem. + */ +static inline int cdebug_show(unsigned int mask, unsigned int subsystem) +{ + return mask & D_CANTMASK || + ((libcfs_debug & mask) && (libcfs_subsystem_debug & subsystem)); +} + #define __CDEBUG(cdls, mask, format, a...) \ do { \ CHECK_STACK(); \ \ - if (((mask) & D_CANTMASK) != 0 || \ - ((libcfs_debug & (mask)) != 0 && \ - (libcfs_subsystem_debug & DEBUG_SUBSYSTEM) != 0)) \ + if (cdebug_show(mask, DEBUG_SUBSYSTEM)) \ libcfs_debug_msg(cdls, DEBUG_SUBSYSTEM, mask, \ __FILE__, __FUNCTION__, __LINE__, \ format, ## a); \ @@ -191,10 +199,14 @@ do { \ } while (0) #else /* !CDEBUG_ENABLED */ +static inline int cdebug_show(unsigned int mask, unsigned int subsystem) +{ + return 0; +} #define CDEBUG(mask, format, a...) (void)(0) #define CDEBUG_LIMIT(mask, format, a...) (void)(0) #warning "CDEBUG IS DISABLED. THIS SHOULD NEVER BE DONE FOR PRODUCTION!" -#endif +#endif #else /* !__KERNEL__ && (!__arch_lib__ || LUSTRE_UTILS) */ @@ -305,9 +317,7 @@ extern int libcfs_debug_vmsg2(cfs_debug_limit_state_t *cdls, #define cdebug_va(cdls, mask, file, func, line, fmt, args) do { \ CHECK_STACK(); \ \ - if (((mask) & D_CANTMASK) != 0 || \ - ((libcfs_debug & (mask)) != 0 && \ - (libcfs_subsystem_debug & DEBUG_SUBSYSTEM) != 0)) \ + if (cdebug_show(mask, DEBUG_SUBSYSTEM)) \ libcfs_debug_vmsg(cdls, DEBUG_SUBSYSTEM, (mask), \ (file), (func), (line), fmt, args); \ } while(0); @@ -315,9 +325,7 @@ extern int libcfs_debug_vmsg2(cfs_debug_limit_state_t *cdls, #define cdebug(cdls, mask, file, func, line, fmt, a...) do { \ CHECK_STACK(); \ \ - if (((mask) & D_CANTMASK) != 0 || \ - ((libcfs_debug & (mask)) != 0 && \ - (libcfs_subsystem_debug & DEBUG_SUBSYSTEM) != 0)) \ + if (cdebug_show(mask, DEBUG_SUBSYSTEM)) \ libcfs_debug_msg(cdls, DEBUG_SUBSYSTEM, (mask), \ (file), (func), (line), fmt, ## a); \ } while(0); -- GitLab