Skip to contentSkip to conversation

unix: convert printks to pr_<level>

PATCH Superseded Wang Weidong 3 participants 7 messages Dec 6, 2013

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 unix: convert printks to pr_<level>

use pr_<level> instead of printk(LEVEL)

---
 net/unix/af_unix.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
net/unix/af_unix.c +6 -4
index 4155ed3..ca98e61 100644
@@ -80,6 +80,9 @@
  *		  with BSD names.
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#define DEBUG
+
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/signal.h>
@@ -366,7 +369,7 @@ static void unix_sock_destructor(struct sock *sk)
 	WARN_ON(!sk_unhashed(sk));
 	WARN_ON(sk->sk_socket);
 	if (!sock_flag(sk, SOCK_DEAD)) {
-		printk(KERN_INFO "Attempt to release alive unix socket: %p\n", sk);
+		pr_info("Attempt to release alive unix socket: %p\n", sk);
 		return;
 	}
 
@@ -378,7 +381,7 @@ static void unix_sock_destructor(struct sock *sk)
 	sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1);
 	local_bh_enable();
 #ifdef UNIX_REFCNT_DEBUG
-	printk(KERN_DEBUG "UNIX %p is destroyed, %ld are still alive.\n", sk,
+	pr_debug("UNIX %p is destroyed, %ld are still alive.\n", sk,
 		atomic_long_read(&unix_nr_socks));
 #endif
 }
@@ -2434,8 +2437,7 @@ static int __init af_unix_init(void)
 
 	rc = proto_register(&unix_proto, 1);
 	if (rc != 0) {
-		printk(KERN_CRIT "%s: Cannot create unix_sock SLAB cache!\n",
-		       __func__);
+		pr_crit("%s: Cannot create unix_sock SLAB cache!\n", __func__);
 		goto out;
 	}
 
Signature · 1 line
1.6.0.2
#1 lore raw
Quoted 12 lines · Wang Weidong

use pr_<level> instead of printk(LEVEL)

---
  net/unix/af_unix.c |   10 ++++++----
  1 files changed, 6 insertions(+), 4 deletions(-)
net/unix/af_unix.c +0 -0
index 4155ed3..ca98e61 100644

net/unix/af_unix.c line 85

Quoted 6 lines
net/unix/af_unix.c +3 -0
@@ -80,6 +80,9 @@
   *		  with BSD names.
   */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#define DEBUG
+

Why do you define DEBUG here ?

Quoted 32 lines
net/unix/af_unix.c +3 -4
  #include <linux/module.h>
  #include <linux/kernel.h>
  #include <linux/signal.h>
@@ -366,7 +369,7 @@ static void unix_sock_destructor(struct sock *sk)
  	WARN_ON(!sk_unhashed(sk));
  	WARN_ON(sk->sk_socket);
  	if (!sock_flag(sk, SOCK_DEAD)) {
-		printk(KERN_INFO "Attempt to release alive unix socket: %p\n", sk);
+		pr_info("Attempt to release alive unix socket: %p\n", sk);
  		return;
  	}
 
@@ -378,7 +381,7 @@ static void unix_sock_destructor(struct sock *sk)
  	sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1);
  	local_bh_enable();
  #ifdef UNIX_REFCNT_DEBUG
-	printk(KERN_DEBUG "UNIX %p is destroyed, %ld are still alive.\n", sk,
+	pr_debug("UNIX %p is destroyed, %ld are still alive.\n", sk,
  		atomic_long_read(&unix_nr_socks));
  #endif
  }
@@ -2434,8 +2437,7 @@ static int __init af_unix_init(void)
 
  	rc = proto_register(&unix_proto, 1);
  	if (rc != 0) {
-		printk(KERN_CRIT "%s: Cannot create unix_sock SLAB cache!\n",
-		       __func__);
+		pr_crit("%s: Cannot create unix_sock SLAB cache!\n", __func__);
  		goto out;
  	}
 
#2 lore raw
Quoted 16 lines · Daniel Borkmann
Quoted 15 lines · Wang Weidong

use pr_<level> instead of printk(LEVEL)

---
  net/unix/af_unix.c |   10 ++++++----
  1 files changed, 6 insertions(+), 4 deletions(-)
net/unix/af_unix.c +0 -0
index 4155ed3..ca98e61 100644
@@ -80,6 +80,9 @@
   *          with BSD names.
   */
 
Quoted 6 lines

net/unix/af_unix.c line 85

Quoted 3 lines
net/unix/af_unix.c +3 -0
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#define DEBUG
+

Why do you define DEBUG here ?

I think the pr_debug != printk(KERN_DEBUG), equal when define DEBUG.

Regards.
Wang

Quoted 35 lines
Quoted 23 lines
net/unix/af_unix.c +2 -2
  #include <linux/module.h>
  #include <linux/kernel.h>
  #include <linux/signal.h>
@@ -366,7 +369,7 @@ static void unix_sock_destructor(struct sock *sk)
      WARN_ON(!sk_unhashed(sk));
      WARN_ON(sk->sk_socket);
      if (!sock_flag(sk, SOCK_DEAD)) {
-        printk(KERN_INFO "Attempt to release alive unix socket: %p\n", sk);
+        pr_info("Attempt to release alive unix socket: %p\n", sk);
          return;
      }
 
@@ -378,7 +381,7 @@ static void unix_sock_destructor(struct sock *sk)
      sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1);
      local_bh_enable();
  #ifdef UNIX_REFCNT_DEBUG
-    printk(KERN_DEBUG "UNIX %p is destroyed, %ld are still alive.\n", sk,
+    pr_debug("UNIX %p is destroyed, %ld are still alive.\n", sk,
          atomic_long_read(&unix_nr_socks));
  #endif
  }

net/unix/af_unix.c static int __init af_unix_init(void) · line 2443

Quoted 9 lines
net/unix/af_unix.c +1 -2
@@ -2434,8 +2437,7 @@ static int __init af_unix_init(void)
 
      rc = proto_register(&unix_proto, 1);
      if (rc != 0) {
-        printk(KERN_CRIT "%s: Cannot create unix_sock SLAB cache!\n",
-               __func__);
+        pr_crit("%s: Cannot create unix_sock SLAB cache!\n", __func__);
          goto out;
      }
 

.

#3 lore raw
Quoted 17 lines · Wang Weidong
Quoted 16 lines · Daniel Borkmann
Quoted 15 lines · Wang Weidong

use pr_<level> instead of printk(LEVEL)

---
   net/unix/af_unix.c |   10 ++++++----
   1 files changed, 6 insertions(+), 4 deletions(-)
net/unix/af_unix.c +0 -0
index 4155ed3..ca98e61 100644
@@ -80,6 +80,9 @@
    *          with BSD names.
    */
 
Quoted 7 lines
Quoted 6 lines

net/unix/af_unix.c line 85

Quoted 3 lines
net/unix/af_unix.c +3 -0
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#define DEBUG
+

Why do you define DEBUG here ?

I think the pr_debug != printk(KERN_DEBUG), equal when define DEBUG.

Ok, then please read Documentation/dynamic-debug-howto.txt

pr_debug() is part of the dynamic debugging framework and can be enabled / disabled at runtime when configured. So that define does not belong here.

#4 lore raw
Quoted 24 lines · Daniel Borkmann
Quoted 23 lines · Wang Weidong
Quoted 22 lines · Daniel Borkmann
Quoted 12 lines · Wang Weidong

use pr_<level> instead of printk(LEVEL)

---
   net/unix/af_unix.c |   10 ++++++----
   1 files changed, 6 insertions(+), 4 deletions(-)
net/unix/af_unix.c +0 -0
index 4155ed3..ca98e61 100644

net/unix/af_unix.c line 85

Quoted 6 lines
net/unix/af_unix.c +3 -0
@@ -80,6 +80,9 @@
    *          with BSD names.
    */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+#define DEBUG
+

Why do you define DEBUG here ?

Quoted 8 lines
Quoted 1 line

I think the pr_debug != printk(KERN_DEBUG), equal when define DEBUG.

Ok, then please read Documentation/dynamic-debug-howto.txt

pr_debug() is part of the dynamic debugging framework and can be enabled / disabled at runtime when configured. So that define does not belong here.

Yes, You are right. I will fix it.

Thanks.

Quoted 1 line
#5 lore raw

PATCH v2 1/1 unix: convert printks to pr_<level>

In reply to Wang Weidong

use pr_<level> instead of printk(LEVEL)

---
 net/unix/af_unix.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
net/unix/af_unix.c +5 -4
index 01625cc..8136222 100644
@@ -80,6 +80,8 @@
  *		  with BSD names.
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/signal.h>
@@ -366,7 +368,7 @@ static void unix_sock_destructor(struct sock *sk)
 	WARN_ON(!sk_unhashed(sk));
 	WARN_ON(sk->sk_socket);
 	if (!sock_flag(sk, SOCK_DEAD)) {
-		printk(KERN_INFO "Attempt to release alive unix socket: %p\n", sk);
+		pr_info("Attempt to release alive unix socket: %p\n", sk);
 		return;
 	}
 
@@ -378,7 +380,7 @@ static void unix_sock_destructor(struct sock *sk)
 	sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1);
 	local_bh_enable();
 #ifdef UNIX_REFCNT_DEBUG
-	printk(KERN_DEBUG "UNIX %p is destroyed, %ld are still alive.\n", sk,
+	pr_debug("UNIX %p is destroyed, %ld are still alive.\n", sk,
 		atomic_long_read(&unix_nr_socks));
 #endif
 }
@@ -2433,8 +2435,7 @@ static int __init af_unix_init(void)
 
 	rc = proto_register(&unix_proto, 1);
 	if (rc != 0) {
-		printk(KERN_CRIT "%s: Cannot create unix_sock SLAB cache!\n",
-		       __func__);
+		pr_crit("%s: Cannot create unix_sock SLAB cache!\n", __func__);
 		goto out;
 	}
 
Signature · 1 line
1.7.12