public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: chenweilong <chenweilong@huawei•com>
To: Joe Perches <joe@perches•com>
Cc: <acme@ghostprotocols•net>, <davem@davemloft•net>,
	<netdev@vger•kernel.org>
Subject: Re: [PATCH 2/2] llc: fix checkpatch errors with space
Date: Fri, 20 Dec 2013 12:52:36 +0800	[thread overview]
Message-ID: <52B3CD14.9050609@huawei.com> (raw)
In-Reply-To: <1387511305.2353.34.camel@joe-AO722>

On 2013/12/20 11:48, Joe Perches wrote:
> On Fri, 2013-12-20 at 11:15 +0800, Chen Weilong wrote:
>> From: Weilong Chen <chenweilong@huawei•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@%02X %pM@%02X %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@vger•kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 
That's very good.
Thanks!

  reply	other threads:[~2013-12-20  4:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-20  3:14 [PATCH 1/2] llc: "foo* bar" should be "foo *bar" Chen Weilong
2013-12-20  3:15 ` [PATCH 2/2] llc: fix checkpatch errors with space Chen Weilong
2013-12-20  3:48   ` Joe Perches
2013-12-20  4:52     ` chenweilong [this message]
2013-12-27 18:06 ` [PATCH 1/2] llc: "foo* bar" should be "foo *bar" David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52B3CD14.9050609@huawei.com \
    --to=chenweilong@huawei$(echo .)com \
    --cc=acme@ghostprotocols$(echo .)net \
    --cc=davem@davemloft$(echo .)net \
    --cc=joe@perches$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox