]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
lib-vsprintf-optimize-put_dec_trunc8-fix
authorGeorge Spelvin <linux@horizon.com>
Wed, 26 Sep 2012 01:34:17 +0000 (11:34 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 27 Sep 2012 07:27:37 +0000 (17:27 +1000)
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:

Signed-off-by: George Spelvin <linux@horizon.com>
Cc: Rabin Vincent <rabin@rab.in>
Cc: Denys Vlasenko <vda.linux@googlemail.com>
Cc: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
lib/vsprintf.c

index f58fc4b1eaf0765bf190c538330cb91a986970c8..c2236f14640fb8c222e030435f3d02cb44d718e3 100644 (file)
@@ -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;
        *buf++ = (r - 10 * q)  + '0'; /* 6 */
        if (q == 0)