Messages in this thread | | | Subject | Re: [PATCH 1/4] Cleaned hexadecimal dump | From | Joe Perches <> | Date | Sat, 07 Mar 2015 18:22:05 -0800 |
| |
On Sat, 2015-03-07 at 12:56 -0500, Adrian Remonda wrote: > Signed-off-by: Adrian Remonda <adrianremonda@gmail.com> [] > diff --git a/Documentation/spi/spidev_test.c b/Documentation/spi/spidev_test.c [] > +static void hexDump(const void *src, size_t length, size_t bLine, char *prefix) > +{
Is there something necessary that print_hex_dump can't do?
> + int i = 0; > + char *address = (char *)src; > + char *line = (char *)address; > + unsigned char c; > + > + printf("%s | ", prefix); > + while (length-- > 0) { > + printf("%02X ", (unsigned char)*address++); > + if (!(++i % bLine) || (length == 0 && i % bLine)) { > + if (length == 0) { > + while (i++ % bLine) > + printf("__ "); > + } > + printf(" | "); /* right close */ > + while (line < address) { > + c = *line++; > + printf("%c", (c < 33 || c == 255) ? 0x2E : c); > + } > + printf("\n"); > + if (length > 0) > + printf("%s | ", prefix); > + } > + } > +}
| |