Skip to contentSkip to conversation

: System & debug output modifications

PATCH Applied Allan Stephens 2 participants 19 messages Apr 28, 2008 – May 5, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover : System & debug output modifications

This patch set includes a number of fixes and cleanups for the code TIPC uses to print its system and debug output. Please see each individual patch for further description.

Summary:

 net/tipc/config.c     |    2 
 net/tipc/core.c       |    6 +
 net/tipc/core.h       |  124 ++++++++++++++++----------
 net/tipc/dbg.c        |  231 ++++++++++++++++++++++++-------------------------
 net/tipc/dbg.h        |   12 +--
 net/tipc/link.c       |   20 +++-
 net/tipc/msg.c        |   10 +-
 net/tipc/name_distr.c |    3 -
 8 files changed, 218 insertions(+), 190 deletions(-)

Allan Stephens (9):
[TIPC]: Simplify log buffer resizing
[TIPC]: Provide feedback when log buffer resizing fails [TIPC]: Fix recursive spinlock invocation in print buffer code [TIPC]: Fix null pointer dereference in debug code [TIPC]: Elimination of print buffer chaining
[TIPC]: Cosmetic cleanup of print buffer code [TIPC]: Cosmetic cleanup of system & debug output declarations [TIPC]: Exclude debug-only print buffer code when not debugging [TIPC]: Update version number to TIPC 1.6.4

Thanks,
Al

#1 lore raw

PATCH 1/9 : Simplify log buffer resizing

This patch simplifies & standardizes the way TIPC's print buffer log is resized. Code to terminate use of the log buffer is eliminated by simply setting the log buffer size to 0 bytes.

---
 net/tipc/config.c |    2 +-
 net/tipc/core.c   |    4 ++--
 net/tipc/dbg.c    |   26 +++++++-------------------
 net/tipc/dbg.h    |    6 +++---
 4 files changed, 13 insertions(+), 25 deletions(-)
net/tipc/config.c +1 -1
index c71337a..91d56f8 100644
@@ -529,7 +529,7 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area
 		break;
 #endif
 	case TIPC_CMD_SET_LOG_SIZE:
-		rep_tlv_buf = tipc_log_resize(req_tlv_area, req_tlv_space);
+		rep_tlv_buf = tipc_log_resize_cmd(req_tlv_area, req_tlv_space);
 		break;
 	case TIPC_CMD_DUMP_LOG:
 		rep_tlv_buf = tipc_log_dump();
net/tipc/core.c +2 -2
index 740aac5..862d415 100644
@@ -182,7 +182,7 @@ static int __init tipc_init(void)
 {
 	int res;
 
-	tipc_log_reinit(CONFIG_TIPC_LOG);
+	tipc_log_resize(CONFIG_TIPC_LOG);
 	info("Activated (version " TIPC_MOD_VER
 	     " compiled " __DATE__ " " __TIME__ ")\n");
 
@@ -209,7 +209,7 @@ static void __exit tipc_exit(void)
 	tipc_core_stop_net();
 	tipc_core_stop();
 	info("Deactivated\n");
-	tipc_log_stop();
+	tipc_log_resize(0);
 }
 
 module_init(tipc_init);
net/tipc/dbg.c +7 -19
index e809d2a..1a8d0a2 100644
@@ -350,43 +350,31 @@ void tipc_dump(struct print_buf *pb, const char *fmt, ...)
 }
 
 /**
- * tipc_log_stop - free up TIPC log print buffer
+ * tipc_log_resize - change the size of the TIPC log buffer
+ * @log_size: print buffer size to use
  */
 
-void tipc_log_stop(void)
+void tipc_log_resize(int log_size)
 {
 	spin_lock_bh(&print_lock);
 	if (TIPC_LOG->buf) {
 		kfree(TIPC_LOG->buf);
 		TIPC_LOG->buf = NULL;
 	}
-	spin_unlock_bh(&print_lock);
-}
-
-/**
- * tipc_log_reinit - (re)initialize TIPC log print buffer
- * @log_size: print buffer size to use
- */
-
-void tipc_log_reinit(int log_size)
-{
-	tipc_log_stop();
-
 	if (log_size) {
 		if (log_size < TIPC_PB_MIN_SIZE)
 			log_size = TIPC_PB_MIN_SIZE;
-		spin_lock_bh(&print_lock);
 		tipc_printbuf_init(TIPC_LOG, kmalloc(log_size, GFP_ATOMIC),
 				   log_size);
-		spin_unlock_bh(&print_lock);
 	}
+	spin_unlock_bh(&print_lock);
 }
 
 /**
- * tipc_log_resize - reconfigure size of TIPC log buffer
+ * tipc_log_resize_cmd - reconfigure size of TIPC log buffer
  */
 
-struct sk_buff *tipc_log_resize(const void *req_tlv_area, int req_tlv_space)
+struct sk_buff *tipc_log_resize_cmd(const void *req_tlv_area, int req_tlv_space)
 {
 	u32 value;
 
@@ -397,7 +385,7 @@ struct sk_buff *tipc_log_resize(const void *req_tlv_area, int req_tlv_space)
 	if (value != delimit(value, 0, 32768))
 		return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
 						   " (log size must be 0-32768)");
-	tipc_log_reinit(value);
+	tipc_log_resize(value);
 	return tipc_cfg_reply_none();
 }
 
net/tipc/dbg.h +3 -3
index c01b085..718a5db 100644
@@ -61,10 +61,10 @@ int  tipc_printbuf_empty(struct print_buf *pb);
 int  tipc_printbuf_validate(struct print_buf *pb);
 void tipc_printbuf_move(struct print_buf *pb_to, struct print_buf *pb_from);
 
-void tipc_log_reinit(int log_size);
-void tipc_log_stop(void);
+void tipc_log_resize(int log_size);
 
-struct sk_buff *tipc_log_resize(const void *req_tlv_area, int req_tlv_space);
+struct sk_buff *tipc_log_resize_cmd(const void *req_tlv_area,
+				    int req_tlv_space);
 struct sk_buff *tipc_log_dump(void);
 
 #endif
Signature · 1 line
1.5.3.2
maintainer Applied
#2 lore raw

Re: [PATCH 1/9 net-next-2.6] [TIPC]: Simplify log buffer resizing

From: Allan Stephens <[email protected]>
Date: Mon, 28 Apr 2008 15:48:38 -0400

Quoted 5 lines

This patch simplifies & standardizes the way TIPC's print buffer log is resized. Code to terminate use of the log buffer is eliminated by simply setting the log buffer size to 0 bytes.

Applied.

#3 lore raw

PATCH 2/9 : Provide feedback when log buffer resizing fails

In reply to Allan Stephens

This patch provides feedback to the user when TIPC is unable to set its log buffer to the requested size.

---
 net/tipc/dbg.c |   13 ++++++++++---
 net/tipc/dbg.h |    4 ++--
 2 files changed, 12 insertions(+), 5 deletions(-)
net/tipc/dbg.c +10 -3
index 1a8d0a2..c680691 100644
@@ -2,7 +2,7 @@
  * net/tipc/dbg.c: TIPC print buffer routines for debugging
  *
  * Copyright (c) 1996-2006, Ericsson AB
- * Copyright (c) 2005-2006, Wind River Systems
+ * Copyright (c) 2005-2007, Wind River Systems
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -354,8 +354,10 @@ void tipc_dump(struct print_buf *pb, const char *fmt, ...)
  * @log_size: print buffer size to use
  */
 
-void tipc_log_resize(int log_size)
+int tipc_log_resize(int log_size)
 {
+	int res = 0;
+
 	spin_lock_bh(&print_lock);
 	if (TIPC_LOG->buf) {
 		kfree(TIPC_LOG->buf);
@@ -366,8 +368,11 @@ void tipc_log_resize(int log_size)
 			log_size = TIPC_PB_MIN_SIZE;
 		tipc_printbuf_init(TIPC_LOG, kmalloc(log_size, GFP_ATOMIC),
 				   log_size);
+		res = !TIPC_LOG->buf;
 	}
 	spin_unlock_bh(&print_lock);
+
+	return res;
 }
 
 /**
@@ -385,7 +390,9 @@ struct sk_buff *tipc_log_resize_cmd(const void *req_tlv_area, int req_tlv_space)
 	if (value != delimit(value, 0, 32768))
 		return tipc_cfg_reply_error_string(TIPC_CFG_INVALID_VALUE
 						   " (log size must be 0-32768)");
-	tipc_log_resize(value);
+	if (tipc_log_resize(value))
+		return tipc_cfg_reply_error_string(
+			"unable to create specified log (log size is now 0)");
 	return tipc_cfg_reply_none();
 }
 
net/tipc/dbg.h +2 -2
index 718a5db..6b00062 100644
@@ -2,7 +2,7 @@
  * net/tipc/dbg.h: Include file for TIPC print buffer routines
  *
  * Copyright (c) 1997-2006, Ericsson AB
- * Copyright (c) 2005-2006, Wind River Systems
+ * Copyright (c) 2005-2007, Wind River Systems
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -61,7 +61,7 @@ int  tipc_printbuf_empty(struct print_buf *pb);
 int  tipc_printbuf_validate(struct print_buf *pb);
 void tipc_printbuf_move(struct print_buf *pb_to, struct print_buf *pb_from);
 
-void tipc_log_resize(int log_size);
+int tipc_log_resize(int log_size);
 
 struct sk_buff *tipc_log_resize_cmd(const void *req_tlv_area,
 				    int req_tlv_space);
Signature · 1 line
1.5.3.2
maintainer Applied
#4 lore raw

Re: [PATCH 2/9 net-next-2.6] [TIPC]: Provide feedback when log buffer resizing fails

From: Allan Stephens <[email protected]>
Date: Mon, 28 Apr 2008 15:48:39 -0400

Quoted 4 lines

This patch provides feedback to the user when TIPC is unable to set its log buffer to the requested size.

Applied.

#5 lore raw

PATCH 3/9 : Fix recursive spinlock invocation in print buffer code

In reply to Allan Stephens

This patch fixes two routines that allow the global print buffer spinlock to be taken recursively.

---
 net/tipc/dbg.c |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)
net/tipc/dbg.c +12 -5
index c680691..834319e 100644
@@ -179,8 +179,10 @@ void tipc_printbuf_move(struct print_buf *pb_to, struct print_buf *pb_from)
 	}
 
 	if (pb_to->size < pb_from->size) {
-		tipc_printbuf_reset(pb_to);
-		tipc_printf(pb_to, "*** PRINT BUFFER MOVE ERROR ***");
+		strcpy(pb_to->buf, "*** PRINT BUFFER MOVE ERROR ***");
+		pb_to->buf[pb_to->size - 1] = ~0;
+		pb_to->crs = strchr(pb_to->buf, 0);
+		pb_to->next = NULL;
 		return;
 	}
 
@@ -405,27 +407,32 @@ struct sk_buff *tipc_log_dump(void)
 	struct sk_buff *reply;
 
 	spin_lock_bh(&print_lock);
-	if (!TIPC_LOG->buf)
+	if (!TIPC_LOG->buf) {
+		spin_unlock_bh(&print_lock);
 		reply = tipc_cfg_reply_ultra_string("log not activated\n");
-	else if (tipc_printbuf_empty(TIPC_LOG))
+	} else if (tipc_printbuf_empty(TIPC_LOG)) {
+		spin_unlock_bh(&print_lock);
 		reply = tipc_cfg_reply_ultra_string("log is empty\n");
+	}
 	else {
 		struct tlv_desc *rep_tlv;
 		struct print_buf pb;
 		int str_len;
 
 		str_len = min(TIPC_LOG->size, 32768u);
+		spin_unlock_bh(&print_lock);
 		reply = tipc_cfg_reply_alloc(TLV_SPACE(str_len));
 		if (reply) {
 			rep_tlv = (struct tlv_desc *)reply->data;
 			tipc_printbuf_init(&pb, TLV_DATA(rep_tlv), str_len);
+			spin_lock_bh(&print_lock);
 			tipc_printbuf_move(&pb, TIPC_LOG);
+			spin_unlock_bh(&print_lock);
 			str_len = strlen(TLV_DATA(rep_tlv)) + 1;
 			skb_put(reply, TLV_SPACE(str_len));
 			TLV_SET(rep_tlv, TIPC_TLV_ULTRA_STRING, NULL, str_len);
 		}
 	}
-	spin_unlock_bh(&print_lock);
 	return reply;
 }
 
Signature · 1 line
1.5.3.2
maintainer Applied
#6 lore raw

Re: [PATCH 3/9 net-next-2.6] [TIPC]: Fix recursive spinlock invocation in print buffer code

From: Allan Stephens <[email protected]>
Date: Mon, 28 Apr 2008 15:48:40 -0400

Quoted 4 lines

This patch fixes two routines that allow the global print buffer spinlock to be taken recursively.

Applied.

#7 lore raw

PATCH 4/9 : Fix null pointer dereference in debug code

In reply to Allan Stephens

This patch eliminates an obsolete use of the DBG_OUTPUT print buffer which could lead to a null pointer crash in tipc_printf() if TIPC's debugging capabilities are configured.

---
 net/tipc/name_distr.c |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
net/tipc/name_distr.c +0 -3
index 39fd161..aecba5c 100644
@@ -41,9 +41,6 @@
 #include "msg.h"
 #include "name_distr.h"
 
-#undef  DBG_OUTPUT
-#define DBG_OUTPUT NULL
-
 #define ITEM_SIZE sizeof(struct distr_item)
 
 /**
Signature · 1 line
1.5.3.2
maintainer Applied
#8 lore raw

Re: [PATCH 4/9 net-next-2.6] [TIPC]: Fix null pointer dereference in debug code

From: Allan Stephens <[email protected]>
Date: Mon, 28 Apr 2008 15:48:41 -0400

Quoted 5 lines

This patch eliminates an obsolete use of the DBG_OUTPUT print buffer which could lead to a null pointer crash in tipc_printf() if TIPC's debugging capabilities are configured.

Applied.

#9 lore raw

PATCH 5/9 : Elimination of print buffer chaining

In reply to Allan Stephens

This patch revamps TIPC's print buffer subsystem to eliminate support for arbitrary chains of print buffers, which were rarely needed and difficult to use safely.

In its place, print buffers can now be configured to echo their output to the system console. This provides an equivalent for the only chaining currently utilized by TIPC, in a faster and more compact manner.

---
 net/tipc/core.h |    7 ++-
 net/tipc/dbg.c  |  163 +++++++++++++++++++++++++------------------------------
 net/tipc/dbg.h  |    4 +-
 3 files changed, 80 insertions(+), 94 deletions(-)
net/tipc/core.h +4 -3
index 325404f..7042ef3 100644
@@ -66,7 +66,6 @@
 
 struct tipc_msg;
 extern struct print_buf *TIPC_NULL, *TIPC_CONS, *TIPC_LOG;
-extern struct print_buf *TIPC_TEE(struct print_buf *, struct print_buf *);
 void tipc_msg_print(struct print_buf*,struct tipc_msg *,const char*);
 void tipc_printf(struct print_buf *, const char *fmt, ...);
 void tipc_dump(struct print_buf*,const char *fmt, ...);
@@ -98,11 +97,13 @@ void tipc_dump(struct print_buf*,const char *fmt, ...);
  * TIPC_CONS		   : system console
  * TIPC_LOG		   : TIPC log buffer
  * &buf			   : user-defined buffer (struct print_buf *)
- * TIPC_TEE(&buf_a,&buf_b) : list of buffers (eg. TIPC_TEE(TIPC_CONS,TIPC_LOG))
+ *
+ * Note: TIPC_LOG is configured to echo its output to the system console;
+ *       user-defined buffers can be configured to do the same thing.
  */
 
 #ifndef TIPC_OUTPUT
-#define TIPC_OUTPUT TIPC_TEE(TIPC_CONS,TIPC_LOG)
+#define TIPC_OUTPUT TIPC_LOG
 #endif
 
 #ifndef DBG_OUTPUT
net/tipc/dbg.c +74 -89

253 lines not on this page · raw message

net/tipc/dbg.h +2 -2
index 6b00062..5ef1bc8 100644
@@ -42,14 +42,14 @@
  * @buf: pointer to character array containing print buffer contents
  * @size: size of character array
  * @crs: pointer to first unused space in character array (i.e. final NUL)
- * @next: used to link print buffers when printing to more than one at a time
+ * @echo: echo output to system console if non-zero
  */
 
 struct print_buf {
 	char *buf;
 	u32 size;
 	char *crs;
-	struct print_buf *next;
+	int echo;
 };
 
 #define TIPC_PB_MIN_SIZE 64	/* minimum size for a print buffer's array */
Signature · 1 line
1.5.3.2
maintainer Applied
#10 lore raw

Re: [PATCH 5/9 net-next-2.6] [TIPC]: Elimination of print buffer chaining

From: Allan Stephens <[email protected]>
Date: Mon, 28 Apr 2008 15:48:42 -0400

Quoted 10 lines

This patch revamps TIPC's print buffer subsystem to eliminate support for arbitrary chains of print buffers, which were rarely needed and difficult to use safely.

In its place, print buffers can now be configured to echo their output to the system console. This provides an equivalent for the only chaining currently utilized by TIPC, in a faster and more compact manner.

Applied.

#11 lore raw

PATCH 6/9 : Cosmetic cleanup of print buffer code

In reply to Allan Stephens

This patch contains changes to make TIPC's print buffer code conform more closely to Linux kernel coding guidelines.

---
 net/tipc/core.h |    6 ++++--
 net/tipc/dbg.c  |   14 +++++++-------
 2 files changed, 11 insertions(+), 9 deletions(-)
net/tipc/core.h +4 -2
index 7042ef3..bc63355 100644
@@ -2,7 +2,7 @@
  * net/tipc/core.h: Include file for TIPC global declarations
  *
  * Copyright (c) 2005-2006, Ericsson AB
- * Copyright (c) 2005-2006, Wind River Systems
+ * Copyright (c) 2005-2007, Wind River Systems
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -65,7 +65,9 @@
 #define assert(i)  BUG_ON(!(i))
 
 struct tipc_msg;
-extern struct print_buf *TIPC_NULL, *TIPC_CONS, *TIPC_LOG;
+extern struct print_buf *const TIPC_NULL;
+extern struct print_buf *const TIPC_CONS;
+extern struct print_buf *const TIPC_LOG;
 void tipc_msg_print(struct print_buf*,struct tipc_msg *,const char*);
 void tipc_printf(struct print_buf *, const char *fmt, ...);
 void tipc_dump(struct print_buf*,const char *fmt, ...);
net/tipc/dbg.c +7 -7
index 8ca9457..cda4968 100644
@@ -49,13 +49,13 @@
  */
 
 static struct print_buf null_buf = { NULL, 0, NULL, 0 };
-struct print_buf *TIPC_NULL = &null_buf;
+struct print_buf *const TIPC_NULL = &null_buf;
 
 static struct print_buf cons_buf = { NULL, 0, NULL, 1 };
-struct print_buf *TIPC_CONS = &cons_buf;
+struct print_buf *const TIPC_CONS = &cons_buf;
 
 static struct print_buf log_buf = { NULL, 0, NULL, 1 };
-struct print_buf *TIPC_LOG = &log_buf;
+struct print_buf *const TIPC_LOG = &log_buf;
 
 /*
  * Locking policy when using print buffers.
@@ -107,7 +107,7 @@ void tipc_printbuf_init(struct print_buf *pb, char *raw, u32 size)
 		pb->buf = NULL;
 	} else if (raw) {
 		pb->buf[0] = 0;
-		pb->buf[size-1] = ~0;
+		pb->buf[size - 1] = ~0;
 	}
 }
 
@@ -118,7 +118,7 @@ void tipc_printbuf_init(struct print_buf *pb, char *raw, u32 size)
 
 void tipc_printbuf_reset(struct print_buf *pb)
 {
-	if (pb->buf != NULL) {
+	if (pb->buf) {
 		pb->crs = pb->buf;
 		pb->buf[0] = 0;
 		pb->buf[pb->size - 1] = ~0;
@@ -158,7 +158,7 @@ int tipc_printbuf_validate(struct print_buf *pb)
 
 	if (pb->buf[pb->size - 1] == 0) {
 		cp_buf = kmalloc(pb->size, GFP_ATOMIC);
-		if (cp_buf != NULL){
+		if (cp_buf) {
 			tipc_printbuf_init(&cb, cp_buf, pb->size);
 			tipc_printbuf_move(&cb, pb);
 			tipc_printbuf_move(pb, &cb);
@@ -205,7 +205,7 @@ void tipc_printbuf_move(struct print_buf *pb_to, struct print_buf *pb_from)
 	/* Copy data from char after cursor to end (if used) */
 
 	len = pb_from->buf + pb_from->size - pb_from->crs - 2;
-	if ((pb_from->buf[pb_from->size-1] == 0) && (len > 0)) {
+	if ((pb_from->buf[pb_from->size - 1] == 0) && (len > 0)) {
 		strcpy(pb_to->buf, pb_from->crs + 1);
 		pb_to->crs = pb_to->buf + len;
 	} else
Signature · 1 line
1.5.3.2
maintainer Applied
#12 lore raw

Re: [PATCH 6/9 net-next-2.6] [TIPC]: Cosmetic cleanup of print buffer code

From: Allan Stephens <[email protected]>
Date: Mon, 28 Apr 2008 15:48:43 -0400

Quoted 4 lines

This patch contains changes to make TIPC's print buffer code conform more closely to Linux kernel coding guidelines.

Applied.

#13 lore raw

PATCH 7/9 : Cosmetic cleanup of system & debug output declarations

In reply to Allan Stephens

This patch contains changes to make TIPC's system & debug message declarations more readable. Declarations have been regrouped and recommented to make it easier to understand what output is generated in both standard and debugging modes. In addition, oversize lines have been fixed to respect the 80 character upper bound used in the kernel.

---
 net/tipc/core.h |  117 +++++++++++++++++++++++++++++++-----------------------
 1 files changed, 67 insertions(+), 50 deletions(-)
net/tipc/core.h +67 -50
index bc63355..d7f3b3c 100644
@@ -59,87 +59,104 @@
 #include <linux/vmalloc.h>
 
 /*
- * TIPC debugging code
+ * TIPC sanity test macros
  */
 
 #define assert(i)  BUG_ON(!(i))
 
-struct tipc_msg;
-extern struct print_buf *const TIPC_NULL;
-extern struct print_buf *const TIPC_CONS;
-extern struct print_buf *const TIPC_LOG;
-void tipc_msg_print(struct print_buf*,struct tipc_msg *,const char*);
-void tipc_printf(struct print_buf *, const char *fmt, ...);
-void tipc_dump(struct print_buf*,const char *fmt, ...);
-
-#ifdef CONFIG_TIPC_DEBUG
-
 /*
- * TIPC debug support included:
- * - system messages are printed to TIPC_OUTPUT print buffer
- * - debug messages are printed to DBG_OUTPUT print buffer
+ * TIPC system monitoring code
  */
 
-#define err(fmt, arg...)  tipc_printf(TIPC_OUTPUT, KERN_ERR "TIPC: " fmt, ## arg)
-#define warn(fmt, arg...) tipc_printf(TIPC_OUTPUT, KERN_WARNING "TIPC: " fmt, ## arg)
-#define info(fmt, arg...) tipc_printf(TIPC_OUTPUT, KERN_NOTICE "TIPC: " fmt, ## arg)
-
-#define dbg(fmt, arg...)  do {if (DBG_OUTPUT != TIPC_NULL) tipc_printf(DBG_OUTPUT, fmt, ## arg);} while(0)
-#define msg_dbg(msg, txt) do {if (DBG_OUTPUT != TIPC_NULL) tipc_msg_print(DBG_OUTPUT, msg, txt);} while(0)
-#define dump(fmt, arg...) do {if (DBG_OUTPUT != TIPC_NULL) tipc_dump(DBG_OUTPUT, fmt, ##arg);} while(0)
-
-
 /*
- * By default, TIPC_OUTPUT is defined to be system console and TIPC log buffer,
- * while DBG_OUTPUT is the null print buffer.  These defaults can be changed
- * here, or on a per .c file basis, by redefining these symbols.  The following
- * print buffer options are available:
+ * TIPC's print buffer subsystem supports the following print buffers:
  *
- * TIPC_NULL		   : null buffer (i.e. print nowhere)
- * TIPC_CONS		   : system console
- * TIPC_LOG		   : TIPC log buffer
- * &buf			   : user-defined buffer (struct print_buf *)
+ * TIPC_NULL : null buffer (i.e. print nowhere)
+ * TIPC_CONS : system console
+ * TIPC_LOG  : TIPC log buffer
+ * &buf	     : user-defined buffer (struct print_buf *)
  *
  * Note: TIPC_LOG is configured to echo its output to the system console;
  *       user-defined buffers can be configured to do the same thing.
  */
 
+extern struct print_buf *const TIPC_NULL;
+extern struct print_buf *const TIPC_CONS;
+extern struct print_buf *const TIPC_LOG;
+
+void tipc_printf(struct print_buf *, const char *fmt, ...);
+void tipc_msg_print(struct print_buf *, struct tipc_msg *, const char *);
+void tipc_dump(struct print_buf *, const char *fmt, ...);
+
+/*
+ * TIPC_OUTPUT is the destination print buffer for system messages.
+ */
+
 #ifndef TIPC_OUTPUT
 #define TIPC_OUTPUT TIPC_LOG
 #endif
 
-#ifndef DBG_OUTPUT
-#define DBG_OUTPUT TIPC_NULL
-#endif
-
-#else
-
 /*
- * TIPC debug support not included:
- * - system messages are printed to system console
- * - debug messages are not printed
+ * TIPC can be configured to send system messages to TIPC_OUTPUT
+ * or to the system console only.
  */
 
+#ifdef CONFIG_TIPC_DEBUG
+
+#define err(fmt, arg...)  tipc_printf(TIPC_OUTPUT, \
+					KERN_ERR "TIPC: " fmt, ## arg)
+#define warn(fmt, arg...) tipc_printf(TIPC_OUTPUT, \
+					KERN_WARNING "TIPC: " fmt, ## arg)
+#define info(fmt, arg...) tipc_printf(TIPC_OUTPUT, \
+					KERN_NOTICE "TIPC: " fmt, ## arg)
+
+#else
+
 #define err(fmt, arg...)  printk(KERN_ERR "TIPC: " fmt , ## arg)
 #define info(fmt, arg...) printk(KERN_INFO "TIPC: " fmt , ## arg)
 #define warn(fmt, arg...) printk(KERN_WARNING "TIPC: " fmt , ## arg)
 
-#define dbg(fmt, arg...) do {} while (0)
-#define msg_dbg(msg,txt) do {} while (0)
-#define dump(fmt,arg...) do {} while (0)
+#endif
 
+/*
+ * DBG_OUTPUT is the destination print buffer for debug messages.
+ * It defaults to the the null print buffer, but can be redefined
+ * (typically in the individual .c files being debugged) to allow
+ * selected debug messages to be generated where needed.
+ */
+
+#ifndef DBG_OUTPUT
+#define DBG_OUTPUT TIPC_NULL
+#endif
 
 /*
- * TIPC_OUTPUT is defined to be the system console, while DBG_OUTPUT is
- * the null print buffer.  Thes ensures that any system or debug messages
- * that are generated without using the above macros are handled correctly.
+ * TIPC can be configured to send debug messages to the specified print buffer
+ * (typically DBG_OUTPUT) or to suppress them entirely.
  */
 
-#undef  TIPC_OUTPUT
-#define TIPC_OUTPUT TIPC_CONS
+#ifdef CONFIG_TIPC_DEBUG
 
-#undef  DBG_OUTPUT
-#define DBG_OUTPUT TIPC_NULL
+#define dbg(fmt, arg...)  \
+	do { \
+		if (DBG_OUTPUT != TIPC_NULL) \
+			tipc_printf(DBG_OUTPUT, fmt, ## arg); \
+	} while (0)
+#define msg_dbg(msg, txt) \
+	do { \
+		if (DBG_OUTPUT != TIPC_NULL) \
+			tipc_msg_print(DBG_OUTPUT, msg, txt); \
+	} while (0)
+#define dump(fmt, arg...) \
+	do { \
+		if (DBG_OUTPUT != TIPC_NULL) \
+			tipc_dump(DBG_OUTPUT, fmt, ##arg); \
+	} while (0)
+
+#else
+
+#define dbg(fmt, arg...)	do {} while (0)
+#define msg_dbg(msg, txt)	do {} while (0)
+#define dump(fmt, arg...)	do {} while (0)
 
 #endif
 
Signature · 1 line
1.5.3.2
maintainer Applied
#14 lore raw

Re: [PATCH 7/9 net-next-2.6] [TIPC]: Cosmetic cleanup of system & debug output declarations

From: Allan Stephens <[email protected]>
Date: Mon, 28 Apr 2008 15:48:44 -0400

Quoted 8 lines

This patch contains changes to make TIPC's system & debug message declarations more readable. Declarations have been regrouped and recommented to make it easier to understand what output is generated in both standard and debugging modes. In addition, oversize lines have been fixed to respect the 80 character upper bound used in the kernel.

Applied.

#15 lore raw

PATCH 8/9 : Exclude debug-only print buffer code when not debugging

In reply to Allan Stephens

This patch modifies TIPC to only exclude debug-related print buffer routines when debugging capabilities are not required. It also fixes up some related #defines that exceed 80 characters.

---
 net/tipc/core.h |   12 ++++++++----
 net/tipc/dbg.c  |    8 ++++++--
 net/tipc/link.c |   20 ++++++++++++++++----
 net/tipc/msg.c  |   10 +++++++---
 4 files changed, 37 insertions(+), 13 deletions(-)
net/tipc/core.h +8 -4
index d7f3b3c..0d783bc 100644
@@ -85,8 +85,6 @@ extern struct print_buf *const TIPC_CONS;
 extern struct print_buf *const TIPC_LOG;
 
 void tipc_printf(struct print_buf *, const char *fmt, ...);
-void tipc_msg_print(struct print_buf *, struct tipc_msg *, const char *);
-void tipc_dump(struct print_buf *, const char *fmt, ...);
 
 /*
  * TIPC_OUTPUT is the destination print buffer for system messages.
@@ -144,20 +142,26 @@ void tipc_dump(struct print_buf *, const char *fmt, ...);
 #define msg_dbg(msg, txt) \
 	do { \
 		if (DBG_OUTPUT != TIPC_NULL) \
-			tipc_msg_print(DBG_OUTPUT, msg, txt); \
+			tipc_msg_dbg(DBG_OUTPUT, msg, txt); \
 	} while (0)
 #define dump(fmt, arg...) \
 	do { \
 		if (DBG_OUTPUT != TIPC_NULL) \
-			tipc_dump(DBG_OUTPUT, fmt, ##arg); \
+			tipc_dump_dbg(DBG_OUTPUT, fmt, ##arg); \
 	} while (0)
 
+void tipc_msg_dbg(struct print_buf *, struct tipc_msg *, const char *);
+void tipc_dump_dbg(struct print_buf *, const char *fmt, ...);
+
 #else
 
 #define dbg(fmt, arg...)	do {} while (0)
 #define msg_dbg(msg, txt)	do {} while (0)
 #define dump(fmt, arg...)	do {} while (0)
 
+#define tipc_msg_dbg(...)	do {} while (0)
+#define tipc_dump_dbg(...)	do {} while (0)
+
 #endif
 
 
net/tipc/dbg.c +6 -2
index cda4968..29ecae8 100644
@@ -263,6 +263,8 @@ void tipc_printf(struct print_buf *pb, const char *fmt, ...)
 	spin_unlock_bh(&print_lock);
 }
 
+#ifdef CONFIG_TIPC_DEBUG
+
 /**
  * print_to_console - write string of bytes to console in multiple chunks
  */
@@ -309,11 +311,11 @@ static void printbuf_dump(struct print_buf *pb)
 }
 
 /**
- * tipc_dump - dump (non-console) print buffer to console
+ * tipc_dump_dbg - dump (non-console) print buffer to console
  * @pb: pointer to print buffer
  */
 
-void tipc_dump(struct print_buf *pb, const char *fmt, ...)
+void tipc_dump_dbg(struct print_buf *pb, const char *fmt, ...)
 {
 	int len;
 
@@ -334,6 +336,8 @@ void tipc_dump(struct print_buf *pb, const char *fmt, ...)
 	spin_unlock_bh(&print_lock);
 }
 
+#endif
+
 /**
  * tipc_log_resize - change the size of the TIPC log buffer
  * @log_size: print buffer size to use
net/tipc/link.c +16 -4
index 2a26a16..bd206eb 100644
@@ -147,9 +147,21 @@ static void link_print(struct link *l_ptr, struct print_buf *buf,
 
 #define LINK_LOG_BUF_SIZE 0
 
-#define dbg_link(fmt, arg...)  do {if (LINK_LOG_BUF_SIZE) tipc_printf(&l_ptr->print_buf, fmt, ## arg); } while(0)
-#define dbg_link_msg(msg, txt) do {if (LINK_LOG_BUF_SIZE) tipc_msg_print(&l_ptr->print_buf, msg, txt); } while(0)
-#define dbg_link_state(txt) do {if (LINK_LOG_BUF_SIZE) link_print(l_ptr, &l_ptr->print_buf, txt); } while(0)
+#define dbg_link(fmt, arg...) \
+	do { \
+		if (LINK_LOG_BUF_SIZE) \
+			tipc_printf(&l_ptr->print_buf, fmt, ## arg); \
+	} while (0)
+#define dbg_link_msg(msg, txt) \
+	do { \
+		if (LINK_LOG_BUF_SIZE) \
+			tipc_msg_dbg(&l_ptr->print_buf, msg, txt); \
+	} while (0)
+#define dbg_link_state(txt) \
+	do { \
+		if (LINK_LOG_BUF_SIZE) \
+			link_print(l_ptr, &l_ptr->print_buf, txt); \
+	} while (0)
 #define dbg_link_dump() do { \
 	if (LINK_LOG_BUF_SIZE) { \
 		tipc_printf(LOG, "\n\nDumping link <%s>:\n", l_ptr->name); \
@@ -1651,7 +1663,7 @@ static void link_retransmit_failure(struct link *l_ptr, struct sk_buff *buf)
 	struct tipc_msg *msg = buf_msg(buf);
 
 	warn("Retransmission failure on link <%s>\n", l_ptr->name);
-	tipc_msg_print(TIPC_OUTPUT, msg, ">RETR-FAIL>");
+	tipc_msg_dbg(TIPC_OUTPUT, msg, ">RETR-FAIL>");
 
 	if (l_ptr->addr) {
 
net/tipc/msg.c +7 -3
index 696a863..38abeba 100644
@@ -41,7 +41,9 @@
 #include "bearer.h"
 
 
-void tipc_msg_print(struct print_buf *buf, struct tipc_msg *msg, const char *str)
+#ifdef CONFIG_TIPC_DEBUG
+
+void tipc_msg_dbg(struct print_buf *buf, struct tipc_msg *msg, const char *str)
 {
 	u32 usr = msg_user(msg);
 	tipc_printf(buf, str);
@@ -315,9 +317,11 @@ void tipc_msg_print(struct print_buf *buf, struct tipc_msg *msg, const char *str
 	}
 	tipc_printf(buf, "\n");
 	if ((usr == CHANGEOVER_PROTOCOL) && (msg_msgcnt(msg))) {
-		tipc_msg_print(buf,msg_get_wrapped(msg),"      /");
+		tipc_msg_dbg(buf, msg_get_wrapped(msg), "      /");
 	}
 	if ((usr == MSG_FRAGMENTER) && (msg_type(msg) == FIRST_FRAGMENT)) {
-		tipc_msg_print(buf,msg_get_wrapped(msg),"      /");
+		tipc_msg_dbg(buf, msg_get_wrapped(msg), "      /");
 	}
 }
+
+#endif
Signature · 1 line
1.5.3.2
maintainer Applied
#16 lore raw

Re: [PATCH 8/9 net-next-2.6] [TIPC]: Exclude debug-only print buffer code when not debugging

From: Allan Stephens <[email protected]>
Date: Mon, 28 Apr 2008 15:48:45 -0400

Quoted 5 lines

This patch modifies TIPC to only exclude debug-related print buffer routines when debugging capabilities are not required. It also fixes up some related #defines that exceed 80 characters.

Applied.

#17 lore raw

PATCH 9/9 : Update version number to TIPC 1.6.4

In reply to Allan Stephens

This patch updates TIPC's version number to 1.6.4.

---
 net/tipc/core.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/tipc/core.c +1 -1
index 862d415..6d6aa5a 100644
@@ -49,7 +49,7 @@
 #include "config.h"
 
 
-#define TIPC_MOD_VER "1.6.3"
+#define TIPC_MOD_VER "1.6.4"
 
 #ifndef CONFIG_TIPC_ZONES
 #define CONFIG_TIPC_ZONES 3
Signature · 1 line
1.5.3.2