Message ID | 20210425095249.177588-1-erik@flodin.me (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | can: proc: fix rcvlist_* header alignment on 64-bit system | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Series ignored based on subject |
Hi, On Sun, 25 Apr 2021 at 11:53, Erik Flodin <erik@flodin.me> wrote: > - seq_puts(m, " device can_id can_mask function" > - " userdata matches ident\n"); > + seq_printf(m, " device can_id can_mask %sfunction%s %suserdata%s matches ident\n", > + pad, pad, pad, pad); > } If a compile-time variant is better I'm happy to change this to e.g. something like this: seq_puts(m, " device can_id can_mask "); if (IS_ENABLED(CONFIG_64BIT)) seq_puts(m, " function userdata "); else seq_puts(m, "function userdata"); seq_puts(m, " matches ident\n"); or something like what Vincent suggested: #ifdef CONFIG_64BIT #define PAD " " #else #define PAD "" #endif ... seq_puts(m, " device can_id can_mask " PAD "function " PAD PAD "userdata " PAD "matches ident\n"); None of these versions are really grep friendly though. If that is needed, a third variant with two full strings can be used instead. Just let me know which one that's preferred. // Erik
On Sun. 25 Apr 2021 at 20:40, Erik Flodin <erik@flodin.me> wrote: > > None of these versions are really grep friendly though. If that is > needed, a third variant with two full strings can be used instead. > Just let me know which one that's preferred. Out of all the propositions, my favorite is the third variant with two full strings. It is optimal in terms of computing time (not that this is a bottleneck...), it can be grepped and the source code is easy to understand.
On 25.04.2021 21:05:41, Vincent MAILHOL wrote: > On Sun. 25 Apr 2021 at 20:40, Erik Flodin <erik@flodin.me> wrote: > > > > None of these versions are really grep friendly though. If that is > > needed, a third variant with two full strings can be used instead. > > Just let me know which one that's preferred. > > Out of all the propositions, my favorite is the third variant > with two full strings. It is optimal in terms of computing > time (not that this is a bottleneck...), it can be grepped and > the source code is easy to understand. +1 Marc
diff --git a/net/can/proc.c b/net/can/proc.c index 5ea8695f507e..9c341ccd097c 100644 --- a/net/can/proc.c +++ b/net/can/proc.c @@ -201,12 +201,14 @@ static void can_print_rcvlist(struct seq_file *m, struct hlist_head *rx_list, static void can_print_recv_banner(struct seq_file *m) { + const char *pad = sizeof(void *) == 8 ? " " : ""; + /* * can1. 00000000 00000000 00000000 * ....... 0 tp20 */ - seq_puts(m, " device can_id can_mask function" - " userdata matches ident\n"); + 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)
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 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)