diff mbox series

can: fix proc/can/net/rcvlist_* header alignment on 64-bit system

Message ID 20210425084950.171529-1-erik@flodin.me (mailing list archive)
State Awaiting Upstream
Delegated to: Netdev Maintainers
Headers show
Series can: fix proc/can/net/rcvlist_* header alignment on 64-bit system | expand

Checks

Context Check Description
netdev/tree_selection success Series ignored based on subject

Commit Message

Erik Flodin April 25, 2021, 8:49 a.m. UTC
Before this fix, the function and userdata columns weren't aligned:
  device   can_id   can_mask  function  userdata   matches  ident
   vcan0  92345678  9fffffff  0000000000000000  0000000000000000         0  raw
   vcan0     123    00000123  0000000000000000  0000000000000000         0  raw

After the fix they are:
  device   can_id   can_mask      function          userdata       matches  ident
   vcan0  92345678  9fffffff  0000000000000000  0000000000000000         0  raw
   vcan0     123    00000123  0000000000000000  0000000000000000         0  raw

Signed-off-by: Erik Flodin <erik@flodin.me>
---
 net/can/proc.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Marc Kleine-Budde April 25, 2021, 9:07 a.m. UTC | #1
Hey Erik,

the subject is not 100% correct, actually it is /proc/net/can/rcvlist_*

On 25.04.2021 10:49:29, Erik Flodin wrote:
> Before this fix, the function and userdata columns weren't aligned:
>   device   can_id   can_mask  function  userdata   matches  ident
>    vcan0  92345678  9fffffff  0000000000000000  0000000000000000         0  raw
>    vcan0     123    00000123  0000000000000000  0000000000000000         0  raw
> 
> After the fix they are:
>   device   can_id   can_mask      function          userdata       matches  ident
>    vcan0  92345678  9fffffff  0000000000000000  0000000000000000         0  raw
>    vcan0     123    00000123  0000000000000000  0000000000000000         0  raw
> 
> Signed-off-by: Erik Flodin <erik@flodin.me>
> ---
>  net/can/proc.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/net/can/proc.c b/net/can/proc.c
> index 5ea8695f507e..97901e56c429 100644
> --- a/net/can/proc.c
> +++ b/net/can/proc.c
> @@ -205,8 +205,11 @@ static void can_print_recv_banner(struct seq_file *m)
>  	 *                  can1.  00000000  00000000  00000000
>  	 *                 .......          0  tp20
>  	 */
> -	seq_puts(m, "  device   can_id   can_mask  function"
> -			"  userdata   matches  ident\n");
> +	const char *pad = sizeof(void *) == 8 ? "    " : "";

nitpick: please move this to the beginning of the function, even before
the comment.

> +
> +	seq_printf(m, "  device   can_id   can_mask  %sfunction%s"
> +		   "  %suserdata%s   matches  ident\n",

nitpick:
For printed strings it's better to have them in a single line, so that
grepping for them is easier.

> +		   pad, pad, pad, pad);
>  }
>  
>  static int can_stats_proc_show(struct seq_file *m, void *v)
> -- 
> 2.31.0
> 
> 

Marc
Erik Flodin April 25, 2021, 9:56 a.m. UTC | #2
Hi,

On Sun, 25 Apr 2021 at 11:07, Marc Kleine-Budde <mkl@pengutronix.de> wrote:
> the subject is not 100% correct, actually it is /proc/net/can/rcvlist_*

Good catch. That was sloppy of me...

> nitpick:
> For printed strings it's better to have them in a single line, so that
> grepping for them is easier.

I wasn't sure if I should keep the existing layout or change it since
the include %s probably makes it hard(er) to grep anyway. But I've
changed it in the fixed patch.

Thanks for your comments!

// Erik
diff mbox series

Patch

diff --git a/net/can/proc.c b/net/can/proc.c
index 5ea8695f507e..97901e56c429 100644
--- a/net/can/proc.c
+++ b/net/can/proc.c
@@ -205,8 +205,11 @@  static void can_print_recv_banner(struct seq_file *m)
 	 *                  can1.  00000000  00000000  00000000
 	 *                 .......          0  tp20
 	 */
-	seq_puts(m, "  device   can_id   can_mask  function"
-			"  userdata   matches  ident\n");
+	const char *pad = sizeof(void *) == 8 ? "    " : "";
+
+	seq_printf(m, "  device   can_id   can_mask  %sfunction%s"
+		   "  %suserdata%s   matches  ident\n",
+		   pad, pad, pad, pad);
 }
 
 static int can_stats_proc_show(struct seq_file *m, void *v)