diff mbox

[U-Boot,4/4] common: cmd_elf.c: use uintptr_t for casts from u32 to void*

Message ID 1347814506-22926-5-git-send-email-daniel.schwierzeck@gmail.com
State Accepted
Delegated to: Tom Rini
Headers show

Commit Message

Daniel Schwierzeck Sept. 16, 2012, 4:55 p.m. UTC
From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

This fixes warnings when compiling with ELDK-5.2.1 for MIPS64:

cmd_elf.c: In function 'load_elf_image_phdr':
cmd_elf.c:289:15: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
cmd_elf.c: In function 'load_elf_image_shdr':
cmd_elf.c:343:12: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
cmd_elf.c:346:12: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

---
 common/cmd_elf.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Tom Rini Sept. 27, 2012, 4:22 p.m. UTC | #1
On Sun, Sep 16, 2012 at 06:55:06AM -0000, Daniel Schwierzeck wrote:

> From: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
> 
> This fixes warnings when compiling with ELDK-5.2.1 for MIPS64:
> 
> cmd_elf.c: In function 'load_elf_image_phdr':
> cmd_elf.c:289:15: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
> cmd_elf.c: In function 'load_elf_image_shdr':
> cmd_elf.c:343:12: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
> cmd_elf.c:346:12: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
> 
> Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

Applied to u-boot/next, thanks!
diff mbox

Patch

diff --git a/common/cmd_elf.c b/common/cmd_elf.c
index 0ca1ac2..84d884c 100644
--- a/common/cmd_elf.c
+++ b/common/cmd_elf.c
@@ -285,7 +285,7 @@  static unsigned long load_elf_image_phdr(unsigned long addr)
 
 	/* Load each program header */
 	for (i = 0; i < ehdr->e_phnum; ++i) {
-		void *dst = (void *) phdr->p_paddr;
+		void *dst = (void *)(uintptr_t) phdr->p_paddr;
 		void *src = (void *) addr + phdr->p_offset;
 		debug("Loading phdr %i to 0x%p (%i bytes)\n",
 			i, dst, phdr->p_filesz);
@@ -340,10 +340,11 @@  static unsigned long load_elf_image_shdr(unsigned long addr)
 		}
 
 		if (shdr->sh_type == SHT_NOBITS) {
-			memset((void *)shdr->sh_addr, 0, shdr->sh_size);
+			memset((void *)(uintptr_t) shdr->sh_addr, 0,
+				shdr->sh_size);
 		} else {
 			image = (unsigned char *) addr + shdr->sh_offset;
-			memcpy((void *) shdr->sh_addr,
+			memcpy((void *)(uintptr_t) shdr->sh_addr,
 				(const void *) image,
 				shdr->sh_size);
 		}