From: Jens Rosenboom <jens@mcbone.net>
To: Joe Perches <joe@perches.com>
Cc: David Miller <davem@davemloft.net>,
chuck.lever@oracle.com, brian.haley@hp.com,
netdev@vger.kernel.org
Subject: Re: [PATCH] lib/vsprintf.c: Add "%pI6c" - print pointer as compressed ipv6 address
Date: Mon, 17 Aug 2009 17:18:29 +0200 [thread overview]
Message-ID: <1250522309.16632.45.camel@fnki-nb00130> (raw)
In-Reply-To: <1250349894.4620.5.camel@Joe-Laptop.home>
On Sat, 2009-08-15 at 08:24 -0700, Joe Perches wrote:
> On Fri, 2009-08-14 at 13:12 -0700, David Miller wrote:
> > I'd say that kernel log messages are OK to tinker with, whereas procfs
> > and sysfs file contents are not.
>
> Here's a patch to start that tinkering with log messages
Two small optimizations:
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 9b79536..a80ef3d 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -677,12 +677,11 @@ static char *ip6_compressed_string(char *p, const
struct in6_addr *addr)
int j;
int range;
unsigned char zerolength[8];
- int longest = 0;
+ int longest = 1;
int colonpos = -1;
u16 word;
u8 hi;
u8 lo;
- bool printhi;
bool needcolon = false;
bool useIPv4 = ipv6_addr_v4mapped(addr) || ipv6_addr_is_isatap(addr);
@@ -707,8 +706,6 @@ static char *ip6_compressed_string(char *p, const
struct in6_addr *addr)
colonpos = i;
}
}
- if (colonpos != -1 && zerolength[colonpos] < 2)
- colonpos = -1;
for (i = 0; i < range; i++) {
if (i == colonpos) {
@@ -729,15 +726,13 @@ static char *ip6_compressed_string(char *p, const
struct in6_addr *addr)
word = ntohs(addr->s6_addr16[i]);
hi = word >> 8;
lo = word & 0xff;
- printhi = false;
if (hi) {
if (hi > 0x0f)
p = pack_hex_byte(p, hi);
else
*p++ = hex_asc_lo(hi);
- printhi = true;
}
- if (printhi || lo > 0x0f)
+ if (hi || lo > 0x0f)
p = pack_hex_byte(p, lo);
else
*p++ = hex_asc_lo(lo);
Also I'm wondering whether it makes sense to pull the format code
checking into all the sub-routines. It might be easier to maintain if it
is all kept together in pointer().
next prev parent reply other threads:[~2009-08-17 15:18 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-12 15:39 [RFC] ipv6: Change %pI6 format to output compacted addresses? Jens Rosenboom
2009-08-13 1:33 ` Brian Haley
2009-08-13 10:39 ` Joe Perches
2009-08-13 13:52 ` Jens Rosenboom
2009-08-13 15:07 ` Joe Perches
2009-08-13 14:39 ` Jens Rosenboom
2009-08-13 15:14 ` Chuck Lever
2009-08-13 16:27 ` Brian Haley
2009-08-13 18:10 ` Joe Perches
2009-08-13 18:15 ` Chuck Lever
2009-08-13 18:21 ` Joe Perches
2009-08-13 18:39 ` Chuck Lever
2009-08-13 19:05 ` Joe Perches
2009-08-13 20:24 ` Brian Haley
2009-08-13 20:28 ` Brian Haley
2009-08-13 20:24 ` Brian Haley
2009-08-13 20:34 ` Joe Perches
2009-08-13 21:02 ` Chuck Lever
2009-08-13 21:13 ` Joe Perches
2009-08-13 23:31 ` David Miller
2009-08-14 6:22 ` Jens Rosenboom
2009-08-14 7:15 ` David Miller
2009-08-14 8:15 ` Jens Rosenboom
2009-08-14 20:12 ` David Miller
2009-08-15 15:24 ` [PATCH] lib/vsprintf.c: Add "%pI6c" - print pointer as compressed ipv6 address Joe Perches
2009-08-16 4:10 ` [RFC PATCH] lib/vsprintf.c: Add struct sockaddr * "%pN<foo>" output Joe Perches
2009-08-19 14:26 ` Chuck Lever
2009-08-19 20:44 ` [RFC PATCH V2] " Joe Perches
2009-08-19 22:20 ` Chuck Lever
2009-08-19 22:36 ` Joe Perches
2009-08-19 23:00 ` Chuck Lever
2009-08-20 4:24 ` Joe Perches
2009-08-20 4:29 ` David Miller
2009-08-17 15:18 ` Jens Rosenboom [this message]
2009-08-17 22:29 ` [PATCH V2] lib/vsprintf.c: Add "%pI6c" - print pointer as compressed ipv6 address Joe Perches
2009-08-18 13:48 ` Jens Rosenboom
2009-08-29 7:20 ` David Miller
2009-08-14 16:26 ` [RFC] ipv6: Change %pI6 format to output compacted addresses? Chuck Lever
2009-08-13 14:18 ` Christoph Hellwig
2009-08-13 14:30 ` Jens Rosenboom
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=1250522309.16632.45.camel@fnki-nb00130 \
--to=jens@mcbone.net \
--cc=brian.haley@hp.com \
--cc=chuck.lever@oracle.com \
--cc=davem@davemloft.net \
--cc=joe@perches.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).