Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1665228 > unrolled thread

Odd use of %14pM in net/batman-adv/distributed-arp-table.c

Started byJoe Perches <joe@perches.com>
First post2017-06-14 00:00 +0200
Last post2017-06-14 21:50 +0200
Articles 6 — 3 participants

Back to article view | Back to linux.kernel


Contents

  Odd use of %14pM in net/batman-adv/distributed-arp-table.c Joe Perches <joe@perches.com> - 2017-06-14 00:00 +0200
    Re: [B.A.T.M.A.N.] Odd use of %14pM in net/batman-adv/distributed-arp-table.c Sven Eckelmann <sven@narfation.org> - 2017-06-14 10:30 +0200
      Re: [B.A.T.M.A.N.] Odd use of %14pM in  net/batman-adv/distributed-arp-table.c Joe Perches <joe@perches.com> - 2017-06-14 11:40 +0200
      [PATCH] batman-adv: Remove unnecessary length qualifier in %14pM Joe Perches <joe@perches.com> - 2017-06-14 11:40 +0200
        Re: [PATCH] batman-adv: Remove unnecessary length qualifier in  %14pM David Miller <davem@davemloft.net> - 2017-06-14 21:30 +0200
        Re: [PATCH] batman-adv: Remove unnecessary length qualifier in %14pM Sven Eckelmann <sven@narfation.org> - 2017-06-14 21:50 +0200

#1665228 — Odd use of %14pM in net/batman-adv/distributed-arp-table.c

FromJoe Perches <joe@perches.com>
Date2017-06-14 00:00 +0200
SubjectOdd use of %14pM in net/batman-adv/distributed-arp-table.c
Message-ID<tS20V-4RM-7@gated-at.bofh.it>
An output mac address is 17 bytes

         1
12345678901234567
00:11:22:33:44:55

but in net/batman-adv/distributed-arp-table.c

int batadv_dat_cache_seq_print_text(struct seq_file *seq, void *offset)
{
[...]
			seq_printf(seq, " * %15pI4 %14pM %4i %6i:%02i\n",
				   &dat_entry->ip, dat_entry->mac_addr,
				   batadv_print_vid(dat_entry->vid),
				   last_seen_mins, last_seen_secs);

%14pM is odd as this should not emit the last byte of the
mac address.  So given the example above, it would output
00:11:22:33:44

Is that what's really desired?

If so, I'd suggest using something more obvious like %5phC

[toc] | [next] | [standalone]


#1665556 — Re: [B.A.T.M.A.N.] Odd use of %14pM in net/batman-adv/distributed-arp-table.c

FromSven Eckelmann <sven@narfation.org>
Date2017-06-14 10:30 +0200
SubjectRe: [B.A.T.M.A.N.] Odd use of %14pM in net/batman-adv/distributed-arp-table.c
Message-ID<tSbQC-2Ni-17@gated-at.bofh.it>
In reply to#1665228

[Multipart message — attachments visible in raw view] — view raw

On Dienstag, 13. Juni 2017 14:51:41 CEST Joe Perches wrote:
> An output mac address is 17 bytes
[...]
> but in net/batman-adv/distributed-arp-table.c
[...]
> %14pM is odd as this should not emit the last byte of the
> mac address.  So given the example above, it would output
> 00:11:22:33:44
[...]

I completely agree too the "wrong length" part. It is currently not omitting 
the last byte:

    Distributed ARP Table (bat0):
              IPv4             MAC        VID   last-seen
     *   10.204.28.206 e8:50:8b:8b:71:8d   -1      4:05
     *    10.204.77.54 6c:2f:2c:43:70:eb   -1      1:56
     *    10.25.21.138 ec:1f:72:c3:15:51   -1      4:21
     *   10.204.27.220 08:70:45:8c:ac:db   -1      2:32
     *   192.168.42.22 64:66:b3:bb:8e:ef   -1      0:18
     *     10.204.64.1 02:ba:7a:df:04:00   -1      0:00
     *   192.168.42.27 e8:de:27:f9:0f:48   -1      0:32

But it definitely also not "correct". I see something similar in the IV OGM
code:

    net/batman-adv/bat_iv_ogm.c:               "bidirectional: orig = %-15pM neigh = %-15pM => own_bcast = %2i, real recv = %2i, local tq: %3i, asym_penalty: %3i, iface_penalty: %3i, total tq: %3i, if_incoming = %s, if_outgoing = %s\n",

Do you want to provide a patch to convert it to simple %pM's?

Kind regards,
	Sven

[toc] | [prev] | [next] | [standalone]


#1665634 — Re: [B.A.T.M.A.N.] Odd use of %14pM in net/batman-adv/distributed-arp-table.c

FromJoe Perches <joe@perches.com>
Date2017-06-14 11:40 +0200
SubjectRe: [B.A.T.M.A.N.] Odd use of %14pM in net/batman-adv/distributed-arp-table.c
Message-ID<tScWm-3r6-11@gated-at.bofh.it>
In reply to#1665556
On Wed, 2017-06-14 at 10:23 +0200, Sven Eckelmann wrote:
> On Dienstag, 13. Juni 2017 14:51:41 CEST Joe Perches wrote:
> > An output mac address is 17 bytes
> 
> [...]
> > but in net/batman-adv/distributed-arp-table.c
> 
> [...]
> > %14pM is odd as this should not emit the last byte of the
> > mac address.  So given the example above, it would output
> > 00:11:22:33:44
> 
> [...]
> 
> I completely agree too the "wrong length" part. It is currently not omitting 
> the last byte:

Right, I only looked at vsprintf.c and mistook precision for
field_width.

Do you want to provide a patch to convert it to simple %pM's?

OK.

[toc] | [prev] | [next] | [standalone]


#1665636 — [PATCH] batman-adv: Remove unnecessary length qualifier in %14pM

FromJoe Perches <joe@perches.com>
Date2017-06-14 11:40 +0200
Subject[PATCH] batman-adv: Remove unnecessary length qualifier in %14pM
Message-ID<tScWm-3r6-13@gated-at.bofh.it>
In reply to#1665556
It's misleading and unnecessary.

Signed-off-by: Joe Perches <joe@perches.com>
---
 net/batman-adv/distributed-arp-table.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c
index 6930d6b50f99..b6cfa78e9381 100644
--- a/net/batman-adv/distributed-arp-table.c
+++ b/net/batman-adv/distributed-arp-table.c
@@ -834,7 +834,7 @@ int batadv_dat_cache_seq_print_text(struct seq_file *seq, void *offset)
 			last_seen_msecs = last_seen_msecs % 60000;
 			last_seen_secs = last_seen_msecs / 1000;
 
-			seq_printf(seq, " * %15pI4 %14pM %4i %6i:%02i\n",
+			seq_printf(seq, " * %15pI4 %pM %4i %6i:%02i\n",
 				   &dat_entry->ip, dat_entry->mac_addr,
 				   batadv_print_vid(dat_entry->vid),
 				   last_seen_mins, last_seen_secs);
-- 
2.10.0.rc2.1.g053435c

[toc] | [prev] | [next] | [standalone]


#1666164 — Re: [PATCH] batman-adv: Remove unnecessary length qualifier in %14pM

FromDavid Miller <davem@davemloft.net>
Date2017-06-14 21:30 +0200
SubjectRe: [PATCH] batman-adv: Remove unnecessary length qualifier in %14pM
Message-ID<tSm9j-MK-3@gated-at.bofh.it>
In reply to#1665636
From: Joe Perches <joe@perches.com>
Date: Wed, 14 Jun 2017 02:33:52 -0700

> It's misleading and unnecessary.
> 
> Signed-off-by: Joe Perches <joe@perches.com>

Simon will you take this into your batman-adv tree?

Thanks.

[toc] | [prev] | [next] | [standalone]


#1666177 — Re: [PATCH] batman-adv: Remove unnecessary length qualifier in %14pM

FromSven Eckelmann <sven@narfation.org>
Date2017-06-14 21:50 +0200
SubjectRe: [PATCH] batman-adv: Remove unnecessary length qualifier in %14pM
Message-ID<tSmsG-Tw-11@gated-at.bofh.it>
In reply to#1665636

[Multipart message — attachments visible in raw view] — view raw

On Mittwoch, 14. Juni 2017 02:33:52 CEST Joe Perches wrote:
> It's misleading and unnecessary.
> 
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
>  net/batman-adv/distributed-arp-table.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

The patch was applied and is currently queued up as 
454ea1866ef45c6f1b747bd27a8203318be72b5d in batadv/net-next.

Thanks,
	Sven

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web