[PATCH 2/4] sandbox: os: common: fix compiler warning in add_image()

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Jul 6 02:28:04 EDT 2020


GCC reports:

  ./arch/sandbox/os/common.c: In function ‘add_image’:
  ./arch/sandbox/os/common.c:271:6: warning: cast to pointer from integer of
  	different size [-Wint-to-pointer-cast]

This is because hf->base is an unsigned long long, with the upper 32 bit
all-zeroes on 32-bit systems. The compiler doesn't see that though.

Change the cast, so we no longer warn.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 arch/sandbox/os/common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c
index 382a92304020..534571c0e668 100644
--- a/arch/sandbox/os/common.c
+++ b/arch/sandbox/os/common.c
@@ -268,7 +268,7 @@ static int add_image(char *str, char *devname_template, int *devname_number)
 	hf->base = (unsigned long)mmap(NULL, hf->size,
 			PROT_READ | (readonly ? 0 : PROT_WRITE),
 			MAP_SHARED, fd, 0);
-	if ((void *)hf->base == MAP_FAILED)
+	if (hf->base == (unsigned long)MAP_FAILED)
 		printf("warning: mmapping %s failed: %s\n", filename, strerror(errno));
 
 	ret = barebox_register_filedev(hf);
-- 
2.27.0




More information about the barebox mailing list