diff mbox

[U-Boot,v4,11/15] dm: Fix printf() strings in the 'dm' command

Message ID 1402082012-4152-12-git-send-email-sjg@chromium.org
State Superseded
Headers show

Commit Message

Simon Glass June 6, 2014, 7:13 p.m. UTC
The values here are int, but the map_to_sysmem() call can return a long.
Add a cast to deal with this.

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

Changes in v4: None
Changes in v3: None
Changes in v2:
- Add new patch to fix printf() strings in the 'dm' command

 test/dm/cmd_dm.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Andre Renaud June 8, 2014, 10:46 p.m. UTC | #1
On 7 June 2014 07:13, Simon Glass <sjg@chromium.org> wrote:
> The values here are int, but the map_to_sysmem() call can return a long.
> Add a cast to deal with this.
...
> -       printf("%s- %s @ %08x", buf, in->name, map_to_sysmem(in));
> +       printf("%s- %s @ %08x", buf, in->name, (uint)map_to_sysmem(in));

If the argument is a long, shouldn't it be printed as long, rather
than possibly truncated to an int?
 printf("%s- %s @ %08lx", buf, in->name, map_to_sysmem(in));

Regards,
Andre
Simon Glass June 12, 2014, 3:34 a.m. UTC | #2
Hi Andre,

On 8 June 2014 18:46, Andre Renaud <andre@bluewatersys.com> wrote:
> On 7 June 2014 07:13, Simon Glass <sjg@chromium.org> wrote:
>> The values here are int, but the map_to_sysmem() call can return a long.
>> Add a cast to deal with this.
> ...
>> -       printf("%s- %s @ %08x", buf, in->name, map_to_sysmem(in));
>> +       printf("%s- %s @ %08x", buf, in->name, (uint)map_to_sysmem(in));
>
> If the argument is a long, shouldn't it be printed as long, rather
> than possibly truncated to an int?
>  printf("%s- %s @ %08lx", buf, in->name, map_to_sysmem(in));

I found that this happened on ARM, where sizeof(int) == sizeof(long)
and was conscious that all addresses in U-Boot are 32-bits at present
- hmmm is that still true?.

But yes that is more correct. I will change it.

Regards,
Simon
diff mbox

Patch

diff --git a/test/dm/cmd_dm.c b/test/dm/cmd_dm.c
index 180661b..8019407 100644
--- a/test/dm/cmd_dm.c
+++ b/test/dm/cmd_dm.c
@@ -23,7 +23,7 @@  static int display_succ(struct udevice *in, char *buf)
 	char local[16];
 	struct udevice *pos, *n, *prev = NULL;
 
-	printf("%s- %s @ %08x", buf, in->name, map_to_sysmem(in));
+	printf("%s- %s @ %08x", buf, in->name, (uint)map_to_sysmem(in));
 	if (in->flags & DM_FLAG_ACTIVATED)
 		puts(" - activated");
 	puts("\n");
@@ -62,7 +62,7 @@  static int do_dm_dump_all(cmd_tbl_t *cmdtp, int flag, int argc,
 	struct udevice *root;
 
 	root = dm_root();
-	printf("ROOT %08x\n", map_to_sysmem(root));
+	printf("ROOT %08x\n", (uint)map_to_sysmem(root));
 	return dm_dump(root);
 }
 
@@ -84,8 +84,8 @@  static int do_dm_dump_uclass(cmd_tbl_t *cmdtp, int flag, int argc,
 		for (ret = uclass_first_device(id, &dev);
 		     dev;
 		     ret = uclass_next_device(&dev)) {
-			printf("  %s @  %08x:\n", dev->name,
-			       map_to_sysmem(dev));
+			printf("  %s @ %08x:\n", dev->name,
+			       (uint)map_to_sysmem(dev));
 		}
 		puts("\n");
 	}