From 7da515c76e6b610cf4d1f9d01f450aebeebef873 Mon Sep 17 00:00:00 2001
From: phil <phil>
Date: Fri, 20 May 2005 22:35:35 +0000
Subject: [PATCH] - Fixes a catstrophic bug introduced in the merge, wherein
 liblustre OBD_ALLOC   wasn't zeroing memory - eliminate CDEBUG helper dupes;
 everything references CDEBUG now - I wanted to keep obd_memory,
 portals_debug, et al in liblustre, but I can't   have those bits compiled
 into userspace utils.  Hence the LUSTRE_UTILS   preprocessor definition to
 distinguish them.

---
 lnet/include/libcfs/libcfs.h | 81 +++++++++++++-----------------------
 lnet/utils/Makefile.am       |  2 +-
 2 files changed, 31 insertions(+), 52 deletions(-)

diff --git a/lnet/include/libcfs/libcfs.h b/lnet/include/libcfs/libcfs.h
index 56c0f95524..375e61eb3d 100644
--- a/lnet/include/libcfs/libcfs.h
+++ b/lnet/include/libcfs/libcfs.h
@@ -115,7 +115,6 @@ extern unsigned int portal_printk;
 #endif
 
 #ifdef __KERNEL__
-#if 1
 #define CDEBUG(mask, format, a...)                                            \
 do {                                                                          \
         CHECK_STACK(CDEBUG_STACK);                                            \
@@ -165,9 +164,33 @@ do {                                                                          \
         }                                                                     \
 } while (0)
 
-#define CWARN(format, a...) CDEBUG(D_WARNING, format, ## a)
-#define CERROR(format, a...) CDEBUG(D_ERROR, format, ## a)
-#define CEMERG(format, a...) CDEBUG(D_EMERG, format, ## a)
+#elif defined(LUSTRE_UTILS)
+
+#define CDEBUG(mask, format, a...)                                      \
+do {                                                                    \
+        if ((mask) & (D_ERROR | D_EMERG | D_WARNING | D_CONSOLE))       \
+                fprintf(stderr, "(%s:%d:%s()) " format,                 \
+                        __FILE__, __LINE__, __FUNCTION__, ## a);        \
+} while (0)
+#define CDEBUG_LIMIT CDEBUG
+
+#else  /* !__KERNEL__ && !LUSTRE_UTILS*/
+
+#define CDEBUG(mask, format, a...)                                      \
+do {                                                                    \
+        if (((mask) & (D_ERROR | D_EMERG | D_WARNING | D_CONSOLE)) ||   \
+            (portal_debug & (mask) &&                                   \
+             portal_subsystem_debug & DEBUG_SUBSYSTEM))                 \
+                fprintf(stderr, "(%s:%d:%s()) " format,                 \
+                        __FILE__, __LINE__, __FUNCTION__, ## a);        \
+} while (0)
+#define CDEBUG_LIMIT CDEBUG
+
+#endif /* !__KERNEL__ */
+
+#define CWARN(format, a...)             CDEBUG(D_WARNING, format, ## a)
+#define CERROR(format, a...)            CDEBUG(D_ERROR, format, ## a)
+#define CEMERG(format, a...)            CDEBUG(D_EMERG, format, ## a)
 
 #define LCONSOLE(mask, format, a...) CDEBUG(D_CONSOLE | (mask), format, ## a)
 #define LCONSOLE_INFO(format, a...)  CDEBUG_LIMIT(D_CONSOLE, format, ## a)
@@ -184,9 +207,8 @@ do {                                                                    \
         goto label;                                                     \
 } while (0)
 
-#define CDEBUG_ENTRY_EXIT (0)
-
-#ifdef CDEBUG_ENTRY_EXIT
+#define CDEBUG_ENTRY_EXIT 1
+#if CDEBUG_ENTRY_EXIT
 
 /*
  * if rc == NULL, we need to code as RETURN((void *)NULL), otherwise
@@ -215,54 +237,11 @@ do {                                                                    \
 #else /* !CDEBUG_ENTRY_EXIT */
 
 #define RETURN(rc) return (rc)
-#define ENTRY
-#define EXIT
-
-#endif /* !CDEBUG_ENTRY_EXIT */
-
-#else /* !1 */
-#define CDEBUG(mask, format, a...)      do { } while (0)
-#define CWARN(format, a...)             printk(KERN_WARNING format, ## a)
-#define CERROR(format, a...)            printk(KERN_ERR format, ## a)
-#define CEMERG(format, a...)            printk(KERN_EMERG format, ## a)
-#define LCONSOLE(mask, format, a...)    printk(format, ## a)
-#define LCONSOLE_INFO(format, a...)     printk(KERN_INFO format, ## a)
-#define LCONSOLE_WARN(format, a...)     printk(KERN_WARNING format, ## a)
-#define LCONSOLE_ERROR(format, a...)    printk(KERN_ERROR format, ## a)
-#define LCONSOLE_EMERG(format, a...)    printk(KERN_EMERG format, ## a)
-#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)
-#endif /* !1 */
-#else /* !__KERNEL__ */
-
-#define CDEBUG(mask, format, a...)                                      \
-do {                                                                    \
-        if (((mask) & (D_ERROR | D_EMERG | D_WARNING | D_CONSOLE)) ||   \
-            (portal_debug & (mask) &&                                   \
-             portal_subsystem_debug & DEBUG_SUBSYSTEM))                 \
-                fprintf(stderr, "(%s:%d:%s()) " format,                 \
-                                  __FILE__, __LINE__, __FUNCTION__,     \
-                                 ## a);                                 \
-} while (0)
-
-#define CWARN(format, a...)             CDEBUG(D_WARNING, format, ## a)
-#define CERROR(format, a...)            CDEBUG(D_ERROR, format, ## a)
-#define CEMERG(format, a...)            CDEBUG(D_EMERG, format, ## a)
 
-#define LCONSOLE(mask, format, a...)    CDEBUG(D_CONSOLE | (mask), format, ## a)
-#define LCONSOLE_INFO(format, a...)     CDEBUG(D_CONSOLE, format, ## a)
-#define LCONSOLE_WARN(format, a...)     CDEBUG(D_CONSOLE | D_WARNING, format, ## a)
-#define LCONSOLE_ERROR(format, a...)    CDEBUG(D_CONSOLE | D_ERROR, format, ## a)
-#define LCONSOLE_EMERG(format, a...)    CDEBUG(D_CONSOLE | D_EMERG, format, ## a)
-
-#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)
+#endif /* !CDEBUG_ENTRY_EXIT */
 
-#endif /* !__KERNEL__ */
 
 #define LUSTRE_SRV_PTL_PID      LUSTRE_PTL_PID
 
diff --git a/lnet/utils/Makefile.am b/lnet/utils/Makefile.am
index 609a430289..70a9ad89a5 100644
--- a/lnet/utils/Makefile.am
+++ b/lnet/utils/Makefile.am
@@ -12,7 +12,7 @@ noinst_LIBRARIES = libuptlctl.a
 endif
 
 libuptlctl_a_SOURCES = portals.c debug.c l_ioctl.c
-libuptlctl_a_CPPFLAGS = $(LLCPPFLAGS)
+libuptlctl_a_CPPFLAGS = $(LLCPPFLAGS) -DLUSTRE_UTILS=1
 libuptlctl_a_CFLAGS = $(LLCFLAGS)
 
 sbin_PROGRAMS = debugctl
-- 
GitLab