[PATCH v2 05/12] display_options: Drop two spaces before the ASCII column

Simon Glass sjg at chromium.org
Sat May 8 15:00:00 CEST 2021


At present with print_buffer() U-Boot shows four spaces between the hex
and ASCII data. Two seems enough and matches print_hex_dump(). Change it.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

(no changes since v1)

 lib/display_options.c |  2 +-
 test/cmd/mem_search.c | 26 +++++++++++++-------------
 test/dm/rtc.c         |  6 +++---
 test/print_ut.c       | 32 ++++++++++++++++----------------
 test/ut.c             |  2 +-
 5 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/lib/display_options.c b/lib/display_options.c
index cd48998b6d4..7752baba2bd 100644
--- a/lib/display_options.c
+++ b/lib/display_options.c
@@ -189,7 +189,7 @@ int print_buffer(ulong addr, const void *data, uint width, uint count,
 				lb.uc[i] = '.';
 		}
 		lb.uc[i] = '\0';
-		printf("    %s\n", lb.uc);
+		printf("  %s\n", lb.uc);
 
 		/* update references */
 		addr += thislinelen * width;
diff --git a/test/cmd/mem_search.c b/test/cmd/mem_search.c
index 94942793a49..f80c9c40687 100644
--- a/test/cmd/mem_search.c
+++ b/test/cmd/mem_search.c
@@ -30,9 +30,9 @@ static int mem_test_ms_b(struct unit_test_state *uts)
 	buf[0x100] = 0x12;
 	ut_assertok(console_record_reset_enable());
 	run_command("ms.b 1 ff 12", 0);
-	ut_assert_nextline("00000030: 00 12 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................");
+	ut_assert_nextline("00000030: 00 12 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................");
 	ut_assert_nextline("--");
-	ut_assert_nextline("000000f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 12    ................");
+	ut_assert_nextline("000000f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 12  ................");
 	ut_assert_nextline("2 matches");
 	ut_assert_console_end();
 
@@ -57,7 +57,7 @@ static int mem_test_ms_w(struct unit_test_state *uts)
 	buf[BUF_SIZE / 2] = 0x1234;
 	ut_assertok(console_record_reset_enable());
 	run_command("ms.w 0 80 1234", 0);
-	ut_assert_nextline("00000030: 0000 0000 1234 0000 0000 0000 0000 0000    ....4...........");
+	ut_assert_nextline("00000030: 0000 0000 1234 0000 0000 0000 0000 0000  ....4...........");
 	ut_assert_nextline("1 match");
 	ut_assert_console_end();
 
@@ -82,7 +82,7 @@ static int mem_test_ms_l(struct unit_test_state *uts)
 	buf[BUF_SIZE / 4] = 0x12345678;
 	ut_assertok(console_record_reset_enable());
 	run_command("ms 0 40 12345678", 0);
-	ut_assert_nextline("00000030: 00000000 00000000 12345678 00000000    ........xV4.....");
+	ut_assert_nextline("00000030: 00000000 00000000 12345678 00000000  ........xV4.....");
 	ut_assert_nextline("1 match");
 	ut_assert_console_end();
 
@@ -212,10 +212,10 @@ static int mem_test_ms_mult(struct unit_test_state *uts)
 	strcpy(buf + BUF_SIZE - strlen(str) + 1, str);
 	ut_assertok(console_record_reset_enable());
 	run_command("ms.b 0 100 68 65 6c 6c 6f", 0);
-	ut_assert_nextline("00000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 68 65    ..............he");
-	ut_assert_nextline("00000020: 6c 6c 6f 00 00 00 00 00 00 00 00 00 00 00 00 00    llo.............");
+	ut_assert_nextline("00000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 68 65  ..............he");
+	ut_assert_nextline("00000020: 6c 6c 6f 00 00 00 00 00 00 00 00 00 00 00 00 00  llo.............");
 	ut_assert_nextline("--");
-	ut_assert_nextline("00000060: 00 00 00 68 65 6c 6c 6f 00 00 00 00 00 00 00 00    ...hello........");
+	ut_assert_nextline("00000060: 00 00 00 68 65 6c 6c 6f 00 00 00 00 00 00 00 00  ...hello........");
 	ut_assert_nextline("2 matches");
 	ut_assert_console_end();
 	unmap_sysmem(buf);
@@ -242,12 +242,12 @@ static int mem_test_ms_s(struct unit_test_state *uts)
 	strcpy(buf + 0xa1, str2);
 	ut_assertok(console_record_reset_enable());
 	run_command("ms.s 0 100 hello", 0);
-	ut_assert_nextline("00000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 68 65    ..............he");
-	ut_assert_nextline("00000020: 6c 6c 6f 00 00 00 00 00 00 00 00 00 00 00 00 00    llo.............");
+	ut_assert_nextline("00000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 68 65  ..............he");
+	ut_assert_nextline("00000020: 6c 6c 6f 00 00 00 00 00 00 00 00 00 00 00 00 00  llo.............");
 	ut_assert_nextline("--");
-	ut_assert_nextline("00000060: 00 00 00 68 65 6c 6c 6f 00 00 00 00 00 00 00 00    ...hello........");
+	ut_assert_nextline("00000060: 00 00 00 68 65 6c 6c 6f 00 00 00 00 00 00 00 00  ...hello........");
 	ut_assert_nextline("--");
-	ut_assert_nextline("000000a0: 00 68 65 6c 6c 6f 74 68 65 72 65 00 00 00 00 00    .hellothere.....");
+	ut_assert_nextline("000000a0: 00 68 65 6c 6c 6f 74 68 65 72 65 00 00 00 00 00  .hellothere.....");
 	ut_assert_nextline("3 matches");
 	ut_assert_console_end();
 
@@ -257,7 +257,7 @@ static int mem_test_ms_s(struct unit_test_state *uts)
 
 	ut_assertok(console_record_reset_enable());
 	run_command("ms.s 0 100 hello there", 0);
-	ut_assert_nextline("000000a0: 00 68 65 6c 6c 6f 74 68 65 72 65 00 00 00 00 00    .hellothere.....");
+	ut_assert_nextline("000000a0: 00 68 65 6c 6c 6f 74 68 65 72 65 00 00 00 00 00  .hellothere.....");
 	ut_assert_nextline("1 match");
 	ut_assert_console_end();
 
@@ -284,7 +284,7 @@ static int mem_test_ms_limit(struct unit_test_state *uts)
 	buf[0x76] = 0x12;
 	ut_assertok(console_record_reset_enable());
 	run_command("ms.b -l2 1 ff 12", 0);
-	ut_assert_nextline("00000030: 00 12 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................");
+	ut_assert_nextline("00000030: 00 12 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................");
 	ut_assert_nextline("--");
 	ut_assert_nextlinen("00000060: 00 00 12 00 00 00 00 00 00 00 00 00 00 00 00 00");
 	ut_assert_nextline("2 matches (repeat command to check for more)");
diff --git a/test/dm/rtc.c b/test/dm/rtc.c
index 8ab997c87d1..c7f9f8f0ce7 100644
--- a/test/dm/rtc.c
+++ b/test/dm/rtc.c
@@ -204,7 +204,7 @@ static int dm_test_rtc_cmd_rw(struct unit_test_state *uts)
 	ut_assert_console_end();
 
 	run_command("rtc read 0x30 2", 0);
-	ut_assert_nextline("00000030: aa bb                                              ..");
+	ut_assert_nextline("00000030: aa bb                                            ..");
 	ut_assert_console_end();
 
 	run_command("rtc dev 1", 0);
@@ -215,7 +215,7 @@ static int dm_test_rtc_cmd_rw(struct unit_test_state *uts)
 	ut_assert_console_end();
 
 	run_command("rtc read 0x30 2", 0);
-	ut_assert_nextline("00000030: cc dd                                              ..");
+	ut_assert_nextline("00000030: cc dd                                            ..");
 	ut_assert_console_end();
 
 	/*
@@ -227,7 +227,7 @@ static int dm_test_rtc_cmd_rw(struct unit_test_state *uts)
 	ut_assert_console_end();
 
 	run_command("rtc read 0x30 2", 0);
-	ut_assert_nextline("00000030: aa bb                                              ..");
+	ut_assert_nextline("00000030: aa bb                                            ..");
 	ut_assert_console_end();
 
 	return 0;
diff --git a/test/print_ut.c b/test/print_ut.c
index b4dc902d0de..9562db6ec3c 100644
--- a/test/print_ut.c
+++ b/test/print_ut.c
@@ -161,52 +161,52 @@ static int print_display_buffer(struct unit_test_state *uts)
 	/* bytes */
 	console_record_reset();
 	print_buffer(0, buf, 1, 0x12, 0);
-	ut_assert_nextline("00000000: 00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff    ..\"3DUfw........");
-	ut_assert_nextline("00000010: 10 00                                              ..");
+	ut_assert_nextline("00000000: 00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff  ..\"3DUfw........");
+	ut_assert_nextline("00000010: 10 00                                            ..");
 	ut_assert_console_end();
 
 	/* line length */
 	console_record_reset();
 	print_buffer(0, buf, 1, 0x12, 8);
-	ut_assert_nextline("00000000: 00 11 22 33 44 55 66 77    ..\"3DUfw");
-	ut_assert_nextline("00000008: 88 99 aa bb cc dd ee ff    ........");
-	ut_assert_nextline("00000010: 10 00                      ..");
+	ut_assert_nextline("00000000: 00 11 22 33 44 55 66 77  ..\"3DUfw");
+	ut_assert_nextline("00000008: 88 99 aa bb cc dd ee ff  ........");
+	ut_assert_nextline("00000010: 10 00                    ..");
 	ut_assert_console_end();
 
 	/* long line */
 	console_record_reset();
 	buf[0x41] = 0x41;
 	print_buffer(0, buf, 1, 0x42, 0x40);
-	ut_assert_nextline("00000000: 00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ..\"3DUfw........................................................");
-	ut_assert_nextline("00000040: 00 41                                                                                                                                                                                              .A");
+	ut_assert_nextline("00000000: 00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ..\"3DUfw........................................................");
+	ut_assert_nextline("00000040: 00 41                                                                                                                                                                                            .A");
 	ut_assert_console_end();
 
 	/* address */
 	console_record_reset();
 	print_buffer(0x12345678, buf, 1, 0x12, 0);
-	ut_assert_nextline("12345678: 00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff    ..\"3DUfw........");
-	ut_assert_nextline("12345688: 10 00                                              ..");
+	ut_assert_nextline("12345678: 00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff  ..\"3DUfw........");
+	ut_assert_nextline("12345688: 10 00                                            ..");
 	ut_assert_console_end();
 
 	/* 16-bit */
 	console_record_reset();
 	print_buffer(0, buf, 2, 9, 0);
-	ut_assert_nextline("00000000: 1100 3322 5544 7766 9988 bbaa ddcc ffee    ..\"3DUfw........");
-	ut_assert_nextline("00000010: 0010                                       ..");
+	ut_assert_nextline("00000000: 1100 3322 5544 7766 9988 bbaa ddcc ffee  ..\"3DUfw........");
+	ut_assert_nextline("00000010: 0010                                     ..");
 	ut_assert_console_end();
 
 	/* 32-bit */
 	console_record_reset();
 	print_buffer(0, buf, 4, 5, 0);
-	ut_assert_nextline("00000000: 33221100 77665544 bbaa9988 ffeeddcc    ..\"3DUfw........");
-	ut_assert_nextline("00000010: 00000010                               ....");
+	ut_assert_nextline("00000000: 33221100 77665544 bbaa9988 ffeeddcc  ..\"3DUfw........");
+	ut_assert_nextline("00000010: 00000010                             ....");
 	ut_assert_console_end();
 
 	/* 64-bit */
 	console_record_reset();
 	print_buffer(0, buf, 8, 3, 0);
-	ut_assert_nextline("00000000: 7766554433221100 ffeeddccbbaa9988    ..\"3DUfw........");
-	ut_assert_nextline("00000010: 0000000000000010                     ........");
+	ut_assert_nextline("00000000: 7766554433221100 ffeeddccbbaa9988  ..\"3DUfw........");
+	ut_assert_nextline("00000010: 0000000000000010                   ........");
 	ut_assert_console_end();
 
 	/* ASCII */
@@ -218,7 +218,7 @@ static int print_display_buffer(struct unit_test_state *uts)
 		buf[4 + i] = 126 + i;
 	buf[8] = 255;
 	print_buffer(0, buf, 1, 10, 0);
-	ut_assert_nextline("00000000: 00 1f 20 21 7e 7f 80 81 ff 99                      .. !~.....");
+	ut_assert_nextline("00000000: 00 1f 20 21 7e 7f 80 81 ff 99                    .. !~.....");
 	ut_assert_console_end();
 
 	unmap_sysmem(buf);
diff --git a/test/ut.c b/test/ut.c
index 350509a2926..1eec2a57dff 100644
--- a/test/ut.c
+++ b/test/ut.c
@@ -151,7 +151,7 @@ int ut_check_console_dump(struct unit_test_state *uts, int total_bytes)
 		if (str[8] != ':' || str[9] != ' ')
 			return 1;
 
-		bytes = len - 8 - 2 - 3 * 16 - 4;
+		bytes = len - 8 - 2 - 3 * 16 - 2;
 		upto += bytes;
 	}
 
-- 
2.31.1.607.g51e8a6a459-goog



More information about the U-Boot mailing list