Re: [PATCH 1/4] Cleaned hexadecimal dump

From: Joe Perches
Date: Sat Mar 07 2015 - 21:22:21 EST


On Sat, 2015-03-07 at 12:56 -0500, Adrian Remonda wrote:
> Signed-off-by: Adrian Remonda <adrianremonda@xxxxxxxxx>
[]
> 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);
> + }
> + }
> +}



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/