Commit b4f51826 authored by Ralf Baechle's avatar Ralf Baechle Committed by Mike Frysinger

Fix conversion of some ROSE addresses.

The ROSE code is using %02x for conversion of the BCD encoded ROSE
address to ASCII resulting in

  # ifconfig rose0 hw rose 0123456789
  # ifconfig rose0
  rose0: flags=128<NOARP>  mtu 249
          rose 01234567ff  txqueuelen 1  (AMPR ROSE)
          RX packets 0  bytes 0 (0.0 B)
          RX errors 0  dropped 0  overruns 0  frame 0
          TX packets 0  bytes 0 (0.0 B)
          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

This is due to the stdio %02x conversion doesn't as the code seems o
expect truncate the converted output to two rightmost digits as illustrated
by this little test case:

  #include <stdio.h>

  static char array[] = { 0x88 };

  int main(int argc, char *argv[])
  {
          printf("%02hx\n", array[0]);

          return 0;
  }

Fixed by replacing the use of %02x with %02hhx.
Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent 80765331
......@@ -59,7 +59,8 @@ static const char *
{
static char buff[12];
snprintf(buff, sizeof(buff), "%02x%02x%02x%02x%02x", ptr[0], ptr[1], ptr[2], ptr[3], ptr[4]);
snprintf(buff, sizeof(buff), "%02hhx%02hhx%02hhx%02hhx%02hhx",
ptr[0], ptr[1], ptr[2], ptr[3], ptr[4]);
buff[10] = '\0';
return (buff);
}
......
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