Skip to content

Commit

Permalink
spi: spidev_test: Improve decoded text part of hex dump
Browse files Browse the repository at this point in the history
- Print spaces as spaces,
  - Do not print characters > 126, as they will be shown as garbage
    in the modern UTF-8 era,
  - Use a normal period instead of its hexadecimal ASCII value,
  - Delimit the text part with pipe symbols on both sides (was left side
    only), without any spaces, to make it clear where the decoded text
    starts and ends,
  - Drop a useless comment.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Geert Uytterhoeven authored and Mark Brown committed Sep 4, 2018
1 parent 3806112 commit 35386df
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions tools/spi/spidev_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ static void hex_dump(const void *src, size_t length, size_t line_size,
while (i++ % line_size)
printf("__ ");
}
printf(" | "); /* right close */
printf(" |");
while (line < address) {
c = *line++;
printf("%c", (c < 33 || c == 255) ? 0x2E : c);
printf("%c", (c < 32 || c > 126) ? '.' : c);
}
printf("\n");
printf("|\n");
if (length > 0)
printf("%s | ", prefix);
}
Expand Down

0 comments on commit 35386df

Please sign in to comment.