From 613f59f0fd3128cd1e3ac0baa8c90198896815ca Mon Sep 17 00:00:00 2001 From: George Spelvin Date: Wed, 26 Sep 2012 11:34:17 +1000 Subject: [PATCH] lib-vsprintf-optimize-put_dec_trunc8-fix Rabin Vincent 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 Cc: Rabin Vincent Cc: Denys Vlasenko Cc: Michal Nazarewicz Signed-off-by: Andrew Morton --- lib/vsprintf.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index f58fc4b1eaf0..c2236f14640f 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; *buf++ = (r - 10 * q) + '0'; /* 6 */ if (q == 0) -- 2.39.5