dect
/
libdect
Archived
13
0
Fork 0

debug: align ascii dump in dect_hexdump() at fixed offset

Use a fixed offset that is independant of the prefix length to align
the ascii dump.

Signed-off-by: Patrick McHardy <kaber@trash.net>
This commit is contained in:
Patrick McHardy 2010-10-13 22:01:34 +02:00
parent 7ade4c338d
commit 3432ee33a5
1 changed files with 6 additions and 3 deletions

View File

@ -58,9 +58,12 @@ void __fmtstring(2, 3) __dect_debug(enum dect_debug_subsys subsys,
void __dect_hexdump(enum dect_debug_subsys subsys, const char *prefix,
const uint8_t *buf, size_t size)
{
unsigned int i, off;
unsigned int i, off, plen = 0;
char hbuf[3 * BLOCKSIZE + 1], abuf[BLOCKSIZE + 1];
for (i = 0; i < strlen(prefix); i++)
plen += prefix[i] == '\t' ? 8 : 1;
for (i = 0; i < size; i++) {
off = i % BLOCKSIZE;
@ -69,8 +72,8 @@ void __dect_hexdump(enum dect_debug_subsys subsys, const char *prefix,
if (off == BLOCKSIZE - 1 || i == size - 1) {
abuf[off + 1] = '\0';
dect_debug(subsys, "%s: %-48s |%s|\n",
prefix, hbuf, abuf);
dect_debug(subsys, "%s: %-*s |%s|\n",
prefix, 64 - plen, hbuf, abuf);
}
}
}