
Hi Heinrich, On Mon, 18 Aug 2025 at 01:00, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
On 16.08.25 01:31, Simon Glass wrote:
From: Simon Glass <sjg@chromium.org>
On platforms where most of the memory is above 4GB, the EFI app may find itself using addresses with 9 or even 10 digits. Expand the width of the columns to cope with this.
Add some double bars across digits 9 and 8 so that it is easier to make the value.
Signed-off-by: Simon Glass <sjg@chromium.org> ---
cmd/meminfo.c | 9 +++++---- test/cmd/meminfo.c | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/cmd/meminfo.c b/cmd/meminfo.c index 5e83d61c2dd..2f83ca27537 100644 --- a/cmd/meminfo.c +++ b/cmd/meminfo.c @@ -19,9 +19,9 @@ static void print_region(const char *name, ulong base, ulong size, ulong *uptop) { ulong end = base + size;
- printf("%-12s %8lx %8lx %8lx", name, base, size, end); + printf("%-12s %10lx %10lx %10lx", name, base, size, end);
Please, use macro PRIxPTR to print with correct length on 32- and 64-bit systems.
Ick, that is really ugly...using a macro to do something for which C defines a format.
We should stop abusing ulong where we mean uintptr_t. It is just creating confusion.
Unfortunately, from my side I believe the opposite. In U-Boot ulong is used to hold addresses and sizes and it keeps things really simple, most of the time. Of course, ulong is defined to be the same as uintptr_t - it's just that U-Boot has long had this convention of using ulong. I don't see any reason to change it. It is shorter and easier to read than uintptr_t. Also bear in mind that U-Boot and Linux specifically choose toolchains with particular sizes for int, long, etc.
Best regards
Heinrich
if (*uptop) - printf(" %8lx", *uptop - end); + printf(" %10lx", *uptop - end); putc('\n'); *uptop = base; } @@ -58,9 +58,10 @@ static int do_meminfo(struct cmd_tbl *cmdtp, int flag, int argc, if (!IS_ENABLED(CONFIG_CMD_MEMINFO_MAP)) return 0;
- printf("\n%-12s %8s %8s %8s %8s\n", "Region", "Base", "Size", "End", + printf("\n%-12s %10s %10s %10s %10s\n", "Region", "|| Base", + "|| Size", "|| End", "Gap"); - printf("------------------------------------------------\n"); + printf("--------------------------------------------------------\n"); upto = 0; if (IS_ENABLED(CONFIG_VIDEO)) print_region("video", gd_video_bottom(), diff --git a/test/cmd/meminfo.c b/test/cmd/meminfo.c index 53b41e3b49e..b2f306d06e2 100644 --- a/test/cmd/meminfo.c +++ b/test/cmd/meminfo.c @@ -17,7 +17,7 @@ static int cmd_test_meminfo(struct unit_test_state *uts) ut_assert_nextline("DRAM: 256 MiB"); ut_assert_nextline_empty();
- ut_assert_nextline("Region Base Size End Gap"); + ut_assert_nextline("Region || Base || Size || End Gap"); ut_assert_nextlinen("-");
/* For now we don't worry about checking the values */
Regards, Simon