diff mbox

[U-Boot,2/6] fdt: Limit printed hex in fdt print and list commands

Message ID 1345235680-16419-2-git-send-email-joe.hershberger@ni.com
State Accepted
Delegated to: Jerry Van Baren
Headers show

Commit Message

Joe Hershberger Aug. 17, 2012, 8:34 p.m. UTC
Prevent printing the entire image in a itb. It is most likely unhelpful
to have the hex of the entire image scroll for minutes on your slow
serial console.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
---
 common/cmd_fdt.c | 36 ++++++++++++++++++++++++------------
 1 file changed, 24 insertions(+), 12 deletions(-)

Comments

Tom Rini Oct. 25, 2012, 8:59 p.m. UTC | #1
On Fri, Aug 17, 2012 at 10:34:36AM -0000, Joe Hershberger wrote:

> Prevent printing the entire image in a itb. It is most likely unhelpful
> to have the hex of the entire image scroll for minutes on your slow
> serial console.
> 
> Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>

This causes:
$ uboot-build.sh sandboxTesting sandbox on -00004-gf0a29d4
Thu Oct 25 13:59:03 MST 2012
Configuring for sandbox board...
   text    data     bss     dec     hex filename
 140245    6332   28472  175049   2abc9 sandbox/u-boot
cmd_fdt.c: In function 'print_data':
cmd_fdt.c:679:32: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
cmd_fdt.c:691:32: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
Jerry Van Baren Oct. 29, 2012, 12:54 a.m. UTC | #2
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Tom, Joe,

On 10/25/2012 04:59 PM, Tom Rini wrote:
> On Fri, Aug 17, 2012 at 10:34:36AM -0000, Joe Hershberger wrote:
> 
>> Prevent printing the entire image in a itb. It is most likely 
>> unhelpful to have the hex of the entire image scroll for minutes 
>> on your slow serial console.
>> 
>> Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
> 
> This causes: $ uboot-build.sh sandboxTesting sandbox on 
> -00004-gf0a29d4 Thu Oct 25 13:59:03 MST 2012 Configuring for 
> sandbox board... text    data     bss     dec     hex filename 
> 140245    6332   28472  175049   2abc9 sandbox/u-boot cmd_fdt.c:
> In function 'print_data': cmd_fdt.c:679:32: warning: cast from
> pointer to integer of different size [-Wpointer-to-int-cast] 
> cmd_fdt.c:691:32: warning: cast from pointer to integer of 
> different size [-Wpointer-to-int-cast]

Sorry, I should have caught that and the 3/6 warning. :-(

I'm tied up with a flight test through Friday (Nov 2) which has been
consuming all my available time.  Joe, can you look at fixing the
warnings?

Thanks,
gvb

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iQEcBAEBAgAGBQJQjdPPAAoJEGOcKeGailWqeSMH/itjpDTCi/dNf3wdDHImpTev
r9A7Ygk01eLhPWlLX5sV9+GziO1x1s8Z9mRbpdIBz4NeA5vaB79wS3D2/S06dxh8
DeSlk3U8eo4tNiI9OysDDp5IyxNXEmje4KkOD8snLIeYKV3/1RDPQYzsLrzlGVJ6
dFjPGNHmjLWzMi4kOSR34b6SIl1xPCUtBUgMfMTN6R8S5JLuJKSn/WUUcXtHpras
yKYfvs1ULkmMg4aEbKzCWFa/a/JJK+XlxU4XQX2Xd7HSISg0eIoOJSV5khTCG8gR
SVCkbF89+XO749a9xL3jyTEz1xMPqFO3KugbnyZGtsOm87VWyuZ/qzR4KdC2rJA=
=ox6g
-----END PGP SIGNATURE-----
diff mbox

Patch

diff --git a/common/cmd_fdt.c b/common/cmd_fdt.c
index 9a5c53e..a008426 100644
--- a/common/cmd_fdt.c
+++ b/common/cmd_fdt.c
@@ -35,6 +35,9 @@ 
 
 #define MAX_LEVEL	32		/* how deeply nested we will go */
 #define SCRATCHPAD	1024		/* bytes of scratchpad memory */
+#ifndef CONFIG_CMD_FDT_MAX_DUMP
+#define CONFIG_CMD_FDT_MAX_DUMP 64
+#endif
 
 /*
  * Global data (for the gd->bd)
@@ -661,19 +664,28 @@  static void print_data(const void *data, int len)
 	}
 
 	if ((len %4) == 0) {
-		const u32 *p;
-
-		printf("<");
-		for (j = 0, p = data; j < len/4; j ++)
-			printf("0x%x%s", fdt32_to_cpu(p[j]), j < (len/4 - 1) ? " " : "");
-		printf(">");
+		if (len > CONFIG_CMD_FDT_MAX_DUMP)
+			printf("* 0x%08x [0x%08x]", (unsigned int)data, len);
+		else {
+			const u32 *p;
+
+			printf("<");
+			for (j = 0, p = data; j < len/4; j++)
+				printf("0x%08x%s", fdt32_to_cpu(p[j]),
+					j < (len/4 - 1) ? " " : "");
+			printf(">");
+		}
 	} else { /* anything else... hexdump */
-		const u8 *s;
-
-		printf("[");
-		for (j = 0, s = data; j < len; j++)
-			printf("%02x%s", s[j], j < len - 1 ? " " : "");
-		printf("]");
+		if (len > CONFIG_CMD_FDT_MAX_DUMP)
+			printf("* 0x%08x [0x%08x]", (unsigned int)data, len);
+		else {
+			const u8 *s;
+
+			printf("[");
+			for (j = 0, s = data; j < len; j++)
+				printf("%02x%s", s[j], j < len - 1 ? " " : "");
+			printf("]");
+		}
 	}
 }