diff options
author | Harvey Harrison <harvey.harrison@gmail.com> | 2008-11-03 20:09:55 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-11-03 20:09:55 -0500 |
commit | b9ac99855dcc0316ba2feee2b0d3e578f8315b75 (patch) | |
tree | 7ca8a4864a3a8f29bc53ab705954c7e7220d2686 | |
parent | 48148938b494cd57029a43c758e9972307a31d2a (diff) |
printk: ipv4 address digits printed in reverse order
put_dec_trunc prints the digits in reverse order and is reversed
inside number(). Continue using put_dec_trunc, but reverse each quad
in ip4_addr_string.
[Noticed by Julius Volz]
Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | lib/vsprintf.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index dd7cc7fa3e77..6897724ff5df 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c | |||
@@ -620,11 +620,15 @@ static char *ip4_addr_string(char *buf, char *end, u8 *addr, int field_width, | |||
620 | int precision, int flags) | 620 | int precision, int flags) |
621 | { | 621 | { |
622 | char ip4_addr[4 * 4]; /* (4 * 3 decimal digits), 3 dots and trailing zero */ | 622 | char ip4_addr[4 * 4]; /* (4 * 3 decimal digits), 3 dots and trailing zero */ |
623 | char temp[3]; /* hold each IP quad in reverse order */ | ||
623 | char *p = ip4_addr; | 624 | char *p = ip4_addr; |
624 | int i; | 625 | int i, digits; |
625 | 626 | ||
626 | for (i = 0; i < 4; i++) { | 627 | for (i = 0; i < 4; i++) { |
627 | p = put_dec_trunc(p, addr[i]); | 628 | digits = put_dec_trunc(temp, addr[i]) - temp; |
629 | /* reverse the digits in the quad */ | ||
630 | while (digits--) | ||
631 | *p++ = temp[digits]; | ||
628 | if (i != 3) | 632 | if (i != 3) |
629 | *p++ = '.'; | 633 | *p++ = '.'; |
630 | } | 634 | } |