[U-Boot] [RFC PATCH v5 2/4] sandbox: Fix compiling warning
York Sun
york.sun at nxp.com
Thu Feb 25 23:36:17 CET 2016
Fix the following compiling warning. Some only occur on 32-bit hosts
disk/part_efi.c: In function 'alloc_read_gpt_entries':
disk/part_efi.c:894:2: warning: format '%zu' expects argument of
type 'size_t', but argument 5 has type 'long unsigned int'
[-Wformat]
disk/part_efi.c:907:4: warning: format '%zX' expects argument of
type 'size_t', but argument 3 has type 'long unsigned int'
[-Wformat]
cmd/lzmadec.c: In function 'do_lzmadec':
cmd/lzmadec.c:39:12: warning: passing argument 2 of
'lzmaBuffToBuffDecompress' from incompatible pointer type
[enabled by default]
include/lzma/../../lib/lzma/LzmaTools.h:17:12: note: expected
'SizeT *' but argument is of type 'long unsigned int *'
lib/hashtable.c: In function 'hexport_r':
lib/hashtable.c:605:2: warning: format '%zu' expects argument of
type 'size_t', but argument 5 has type 'long unsigned int'
[-Wformat]
lib/hashtable.c:661:5: warning: format '%zu' expects argument of
type 'size_t', but argument 2 has type 'long unsigned int'
[-Wformat]
lib/hashtable.c:661:5: warning: format '%zu' expects argument of
type 'size_t', but argument 3 has type 'long unsigned int'
[-Wformat]
lib/hashtable.c: In function 'himport_r':
lib/hashtable.c:793:3: warning: format '%zu' expects argument of
type 'size_t', but argument 2 has type 'long unsigned int'
[-Wformat]
Signed-off-by: York Sun <york.sun at nxp.com>
---
Changes in v5:
Revise commit message
Drop % sign in PRIpa macro
Use %#08llx instead of %08llx when applicable
Changes in v4:
New patch to fix compiling warnings for sandbox built on 32-bit host
Still need to change CONFIG_SANDBOX_BITS_PER_LONG to 32 to avoid
these warnings
include/asm-generic/bitops/__fls.h:17:2: warning: left shift
count >= width of type [enabled by default]
include/asm-generic/bitops/__fls.h:19:3: warning: left shift
count >= width of type [enabled by default]
include/asm-generic/bitops/__fls.h:22:2: warning: left shift
count >= width of type [enabled by default]
include/asm-generic/bitops/__fls.h:26:2: warning: left shift
count >= width of type [enabled by default]
include/asm-generic/bitops/__fls.h:30:2: warning: left shift
count >= width of type [enabled by default]
include/asm-generic/bitops/__fls.h:34:2: warning: left shift
count >= width of type [enabled by default]
include/asm-generic/bitops/__fls.h:38:2: warning: left shift
count >= width of type [enabled by default]
Changes in v3: None
Changes in v2: None
arch/sandbox/cpu/cpu.c | 3 ++-
arch/sandbox/include/asm/types.h | 9 +++++++--
arch/sandbox/lib/bootm.c | 3 ++-
arch/sandbox/lib/pci_io.c | 2 +-
cmd/lzmadec.c | 5 +++--
disk/part_efi.c | 2 +-
lib/hashtable.c | 2 +-
7 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c
index 196f3e1..5220b08 100644
--- a/arch/sandbox/cpu/cpu.c
+++ b/arch/sandbox/cpu/cpu.c
@@ -62,7 +62,8 @@ void *map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags)
map_dev = NULL;
if (enable_pci_map && !pci_map_physmem(paddr, &len, &map_dev, &ptr)) {
if (plen != len) {
- printf("%s: Warning: partial map at %x, wanted %lx, got %lx\n",
+ printf("%s: Warning: partial map at %" PRIpa
+ ", wanted %lx, got %lx\n",
__func__, paddr, len, plen);
}
map_len = len;
diff --git a/arch/sandbox/include/asm/types.h b/arch/sandbox/include/asm/types.h
index 42c09e2..11b521d 100644
--- a/arch/sandbox/include/asm/types.h
+++ b/arch/sandbox/include/asm/types.h
@@ -53,8 +53,13 @@ typedef __UINT64_TYPE__ u64;
#define BITS_PER_LONG CONFIG_SANDBOX_BITS_PER_LONG
typedef unsigned long dma_addr_t;
-typedef u32 phys_addr_t;
-typedef u32 phys_size_t;
+#if defined(CONFIG_PHYS_64BIT) || (BITS_PER_LONG > 32)
+/* To be consistent with print format %llx */
+typedef unsigned long long phys_addr_t;
+#else
+typedef unsigned long phys_addr_t;
+#endif
+typedef unsigned long phys_size_t;
#endif /* __KERNEL__ */
diff --git a/arch/sandbox/lib/bootm.c b/arch/sandbox/lib/bootm.c
index d49c927..2c15883 100644
--- a/arch/sandbox/lib/bootm.c
+++ b/arch/sandbox/lib/bootm.c
@@ -54,7 +54,8 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
{
if (flag & (BOOTM_STATE_OS_GO | BOOTM_STATE_OS_FAKE_GO)) {
bootstage_mark(BOOTSTAGE_ID_RUN_OS);
- printf("## Transferring control to Linux (at address %08lx)...\n",
+ printf("## Transferring control to Linux (at address %#08" PRIpa
+ ")...\n",
images->ep);
reset_cpu(0);
}
diff --git a/arch/sandbox/lib/pci_io.c b/arch/sandbox/lib/pci_io.c
index 0de124f..f79ea0a 100644
--- a/arch/sandbox/lib/pci_io.c
+++ b/arch/sandbox/lib/pci_io.c
@@ -35,7 +35,7 @@ int pci_map_physmem(phys_addr_t paddr, unsigned long *lenp,
return 0;
}
- debug("%s: failed: addr=%x\n", __func__, paddr);
+ debug("%s: failed: addr=%" PRIpa "\n", __func__, paddr);
return -ENOSYS;
}
diff --git a/cmd/lzmadec.c b/cmd/lzmadec.c
index 1ad9ed6..8e370ef 100644
--- a/cmd/lzmadec.c
+++ b/cmd/lzmadec.c
@@ -20,7 +20,7 @@
static int do_lzmadec(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
{
unsigned long src, dst;
- unsigned long src_len = ~0UL, dst_len = ~0UL;
+ SizeT src_len = ~0UL, dst_len = ~0UL;
int ret;
switch (argc) {
@@ -40,7 +40,8 @@ static int do_lzmadec(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
if (ret != SZ_OK)
return 1;
- printf("Uncompressed size: %ld = 0x%lX\n", src_len, src_len);
+ printf("Uncompressed size: %ld = 0x%lX\n",
+ (ulong)src_len, (ulong)src_len);
setenv_hex("filesize", src_len);
return 0;
diff --git a/disk/part_efi.c b/disk/part_efi.c
index e1b58c5..a59527b 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -10,7 +10,6 @@
* when CONFIG_SYS_64BIT_LBA is not defined, lbaint_t is 32 bits; this
* limits the maximum size of addressable storage to < 2 Terra Bytes
*/
-#include <asm/unaligned.h>
#include <common.h>
#include <command.h>
#include <ide.h>
@@ -19,6 +18,7 @@
#include <memalign.h>
#include <part_efi.h>
#include <linux/ctype.h>
+#include <asm/unaligned.h>
DECLARE_GLOBAL_DATA_PTR;
diff --git a/lib/hashtable.c b/lib/hashtable.c
index 02b4105..6cd076d 100644
--- a/lib/hashtable.c
+++ b/lib/hashtable.c
@@ -13,6 +13,7 @@
* SPDX-License-Identifier: LGPL-2.1+
*/
+#include <common.h>
#include <errno.h>
#include <malloc.h>
@@ -29,7 +30,6 @@
# endif
# endif
#else /* U-Boot build */
-# include <common.h>
# include <linux/string.h>
# include <linux/ctype.h>
#endif
--
1.7.9.5
More information about the U-Boot
mailing list