Commit a2dbaf7e authored by Richael Zhuang's avatar Richael Zhuang Committed by Tomasz Zawadzki
Browse files

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: default avatarRichael Zhuang <richael.zhuang@arm.com>
Change-Id: Iaf3f33c5ce68920ada83c59277f89a547e8030d7
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1739


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent 9fe50848
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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;
		}
+2 −0
Original line number Diff line number Diff line
@@ -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();
}