lkml.org 
[lkml]   [2015]   [Mar]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 1/4] Cleaned hexadecimal dump
From
Date
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);
> + }
> + }
> +}





\
 
 \ /
  Last update: 2015-03-08 03:41    [W:0.096 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site