From 1db6c18e60c8f3676faeb3f3ef87e58d144fb15f Mon Sep 17 00:00:00 2001 From: Darek Stojaczyk Date: Thu, 25 Apr 2019 11:07:42 +0200 Subject: [PATCH] log/fdump: fix alignment of the last printed line Our log_ut currently dumps two buffers which end up being printed with a different column alignment. `00000000 6c 6f 67 20 64 75 6d 70 log dump` vs `00000000 73 70 64 6b 20 64 75 6d 70 spdk dump` In short dumps (len % 16 < 8) we didn't include the extra arbitrary whitespace between the 8-byte parts. Change-Id: I00bf1d334f71370922d939c4397a479f8d707112 Signed-off-by: Darek Stojaczyk Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/452058 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Ben Walker Reviewed-by: Shuhei Matsumoto --- lib/log/log.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/log/log.c b/lib/log/log.c index fe40e8ea8..654dea3a7 100644 --- a/lib/log/log.c +++ b/lib/log/log.c @@ -174,6 +174,11 @@ fdump(FILE *fp, const char *label, const uint8_t *buf, size_t len) buf16[idx % 16] = isprint(buf[idx]) ? buf[idx] : '.'; } for (; idx % 16 != 0; idx++) { + if (idx == 8) { + total += snprintf(tmpbuf + total, sizeof tmpbuf - total, + " "); + } + total += snprintf(tmpbuf + total, sizeof tmpbuf - total, " "); buf16[idx % 16] = ' '; }