lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 19 Dec 2013 19:48:25 -0800
From:	Joe Perches <joe@...ches.com>
To:	Chen Weilong <chenweilong@...wei.com>
Cc:	acme@...stprotocols.net, davem@...emloft.net,
	netdev@...r.kernel.org
Subject: Re: [PATCH 2/2] llc: fix checkpatch errors with space

On Fri, 2013-12-20 at 11:15 +0800, Chen Weilong wrote:
> From: Weilong Chen <chenweilong@...wei.com>
[]
> diff --git a/net/llc/llc_proc.c b/net/llc/llc_proc.c
> index 1a3c7e0..abf28eb 100644
> --- a/net/llc/llc_proc.c
> +++ b/net/llc/llc_proc.c
> @@ -142,7 +142,7 @@ static int llc_seq_socket_show(struct seq_file *seq, void *v)
>  	if (llc->dev)
>  		llc_ui_format_mac(seq, llc->dev->dev_addr);
>  	else {
> -		u8 addr[6] = {0,0,0,0,0,0};
> +		u8 addr[6] = {0, 0, 0, 0, 0, 0};
>  		llc_ui_format_mac(seq, addr);

No need to constantly reinitialize addr and the
static function llc_ui_format_mac is pretty useless.

Perhaps this instead?

Consolidate multiple seq_printfs to a single call.
Remove unnecessary llc_ui_format_mac and use %pM directly.

---
 net/llc/llc_proc.c | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/net/llc/llc_proc.c b/net/llc/llc_proc.c
index 1a3c7e0..f264038 100644
--- a/net/llc/llc_proc.c
+++ b/net/llc/llc_proc.c
@@ -26,11 +26,6 @@
 #include <net/llc_c_st.h>
 #include <net/llc_conn.h>
 
-static void llc_ui_format_mac(struct seq_file *seq, u8 *addr)
-{
-	seq_printf(seq, "%pM", addr);
-}
-
 static struct sock *llc_get_sk_idx(loff_t pos)
 {
 	struct llc_sap *sap;
@@ -125,6 +120,7 @@ static void llc_seq_stop(struct seq_file *seq, void *v)
 
 static int llc_seq_socket_show(struct seq_file *seq, void *v)
 {
+	static const u8 null_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0};
 	struct sock* sk;
 	struct llc_sock *llc;
 
@@ -137,17 +133,11 @@ static int llc_seq_socket_show(struct seq_file *seq, void *v)
 	llc = llc_sk(sk);
 
 	/* FIXME: check if the address is multicast */
-	seq_printf(seq, "%2X  %2X ", sk->sk_type, 0);
-
-	if (llc->dev)
-		llc_ui_format_mac(seq, llc->dev->dev_addr);
-	else {
-		u8 addr[6] = {0,0,0,0,0,0};
-		llc_ui_format_mac(seq, addr);
-	}
-	seq_printf(seq, "@%02X ", llc->sap->laddr.lsap);
-	llc_ui_format_mac(seq, llc->daddr.mac);
-	seq_printf(seq, "@%02X %8d %8d %2d %3u %4d\n", llc->daddr.lsap,
+	seq_printf(seq, "%2X  %2X %pM@...X %pM@...X %8d %8d %2d %3u %4d\n",
+		   sk->sk_type, 0,
+		   llc->dev ? llc->dev->dev_addr : null_addr,
+		   llc->sap->laddr.lsap,
+		   llc->daddr.mac, llc->daddr.lsap,
 		   sk_wmem_alloc_get(sk),
 		   sk_rmem_alloc_get(sk) - llc->copied_seq,
 		   sk->sk_state,



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ