lkml.org 
[lkml]   [2012]   [Sep]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH 3/4] lib: vsprintf: Optimize put_dec_trunc8
Rabin Vincent <rabin@rab.in> wrote:
> This patch breaks IP address printing with "%pI4" (and by extension,
> nfsroot). Example:
>
> - Before: 10.0.0.1
> - After: 10...1

Mea culpa, and thank you for catching it! As I said in my earlier
comment, I tested this most extensively wrapped by some sprintf code
that liked 0 converted to a 0-length string, as that works naturally
with the ANSI spec for %.0u. And it turns out not to matter for the
usual printf code, as num_to_str special-cases that anyway.

The fix is straightforward:

diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index e755083..9872855 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -180,8 +180,6 @@ char *put_dec_trunc8(char *buf, unsigned r)
*buf++ = q - 10*r;
}

- if (r == 0)
- return buf;
q = (r * 0x199a) >> 16; /* r <= 9999 */
*buf++ = (r - 10 * q) + '0';
if (q == 0)
Inspired by Michal Nazarewicz, I have some ideas for more tweaking to
that code.


AKPM: How should I submit this to you? Would you like it as a fixup
patch, or would you like a revised patch from baseline? You're free to
do either manually and add my Signed-off-by: to the result if you want
the fix faster.

I'm also working on addressing Denys Vlasenko's comments, but I figure
the bugfix is more urgent.


\
 
 \ /
  Last update: 2012-09-24 17:21    [W:0.154 / U:0.024 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site