Commit b9ac9985 authored by Harvey Harrison's avatar Harvey Harrison Committed by David S. Miller

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: default avatarHarvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 48148938
...@@ -620,11 +620,15 @@ static char *ip4_addr_string(char *buf, char *end, u8 *addr, int field_width, ...@@ -620,11 +620,15 @@ static char *ip4_addr_string(char *buf, char *end, u8 *addr, int field_width,
int precision, int flags) int precision, int flags)
{ {
char ip4_addr[4 * 4]; /* (4 * 3 decimal digits), 3 dots and trailing zero */ char ip4_addr[4 * 4]; /* (4 * 3 decimal digits), 3 dots and trailing zero */
char temp[3]; /* hold each IP quad in reverse order */
char *p = ip4_addr; char *p = ip4_addr;
int i; int i, digits;
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
p = put_dec_trunc(p, addr[i]); digits = put_dec_trunc(temp, addr[i]) - temp;
/* reverse the digits in the quad */
while (digits--)
*p++ = temp[digits];
if (i != 3) if (i != 3)
*p++ = '.'; *p++ = '.';
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment