log: spdk_log_dump more characters than required
When the size of input buffer is larger than 16 and not divisible by 16, the final line will keep part of the characters of the last line. For example, if I want to dump "spdk dump 16 more chars",the output is: 00000000 "hexadecimal" spdk dump 16 mor 00000010 "hexadecimal" e charsmp 16 mor But the correct should be: 00000000 "hexadecimal" spdk dump 16 mor 00000010 "hexadecimal" e chars Signed-off-by: Richael Zhuang <richael.zhuang@arm.com> Change-Id: Iaf3f33c5ce68920ada83c59277f89a547e8030d7 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1739 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
9fe5084860
commit
a2dbaf7e83
@ -177,6 +177,7 @@ fdump(FILE *fp, const char *label, const uint8_t *buf, size_t len)
|
||||
if (idx != 0 && idx % 16 == 0) {
|
||||
snprintf(tmpbuf + total, sizeof tmpbuf - total,
|
||||
" %s", buf16);
|
||||
memset(buf16, 0, sizeof buf16);
|
||||
fprintf(fp, "%s\n", tmpbuf);
|
||||
total = 0;
|
||||
}
|
||||
|
@ -80,6 +80,8 @@ log_test(void)
|
||||
SPDK_DEBUGLOG(SPDK_LOG_LOG, "log test\n");
|
||||
SPDK_LOGDUMP(SPDK_LOG_LOG, "log dump test:", "log dump", 8);
|
||||
spdk_log_dump(stderr, "spdk dump test:", "spdk dump", 9);
|
||||
/* Test spdk_log_dump with more than 16 chars and less than 32 chars */
|
||||
spdk_log_dump(stderr, "spdk dump test:", "spdk dump 16 more chars", 23);
|
||||
|
||||
spdk_log_close();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user