summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2010-10-13 22:01:34 +0200
committerPatrick McHardy <kaber@trash.net>2010-10-13 22:01:34 +0200
commit3432ee33a5f92044d7133f553e2bcbc05b5b031a (patch)
tree0036995d3f5f89a4ce325a35e1a54c4040b141de /src
parent7ade4c338def50b1bf4dc35a666b41670300ea6c (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/debug.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/debug.c b/src/debug.c
index 37364fa..0255c7b 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -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);
}
}
}