Re: [U-Boot] [RFC PATCH v4 1/3] sandbox: Fix compiling warning on 32-bit host

2016-02-23 Thread york sun
On 02/16/2016 08:01 AM, Simon Glass wrote:
> +Masahiro
> 
> Hi York,
> 
> On 12 February 2016 at 13:59, York Sun  wrote:
>> Fix the following compiling warning on 32-bit host
>>
>> 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 
>>
>> ---
>>
>> 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 |4 ++--
>>  arch/sandbox/lib/bootm.c |3 ++-
>>  arch/sandbox/lib/pci_io.c|2 +-
>>  cmd/bootm.c  |4 ++--
>>  cmd/lzmadec.c|5 +++--
>>  disk/part_efi.c  |2 +-
>>  include/image.h  |6 ++
>>  lib/hashtable.c  |2 +-
>>  9 files changed, 20 insertions(+), 11 deletions(-)
> 
> I think this makes sense. But one nit - the % is not included in the
> macros in inttypes,h. What do you think about doing the same with your
> macro?

Sure. I can drop the % sign in the macro.

> 
>>
>> diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c
>> index 196f3e1..7aad876 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..c3bb76e 100644
>> --- a/arch/sandbox/include/asm/types.h
>> +++ b/arch/sandbox/include/asm/types.h
>> @@ -53,8 +53,8 @@ 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;
>> +typedef unsigned long phys_addr_t;
>> +typedef unsigned long phys_size_t;
>>
>>  #endif /* __KERNEL__ */
>>
>> diff --git a/arch/sandbox/lib/bootm.c b/arch/sandbox/lib/bootm.c
>> index d49c927..9ca89b5 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);
>> -  

Re: [U-Boot] [RFC PATCH v4 1/3] sandbox: Fix compiling warning on 32-bit host

2016-02-16 Thread Simon Glass
+Masahiro

Hi York,

On 12 February 2016 at 13:59, York Sun  wrote:
> Fix the following compiling warning on 32-bit host
>
> 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 
>
> ---
>
> 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 |4 ++--
>  arch/sandbox/lib/bootm.c |3 ++-
>  arch/sandbox/lib/pci_io.c|2 +-
>  cmd/bootm.c  |4 ++--
>  cmd/lzmadec.c|5 +++--
>  disk/part_efi.c  |2 +-
>  include/image.h  |6 ++
>  lib/hashtable.c  |2 +-
>  9 files changed, 20 insertions(+), 11 deletions(-)

I think this makes sense. But one nit - the % is not included in the
macros in inttypes,h. What do you think about doing the same with your
macro?

>
> diff --git a/arch/sandbox/cpu/cpu.c b/arch/sandbox/cpu/cpu.c
> index 196f3e1..7aad876 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..c3bb76e 100644
> --- a/arch/sandbox/include/asm/types.h
> +++ b/arch/sandbox/include/asm/types.h
> @@ -53,8 +53,8 @@ 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;
> +typedef unsigned long phys_addr_t;
> +typedef unsigned long phys_size_t;
>
>  #endif /* __KERNEL__ */
>
> diff --git a/arch/sandbox/lib/bootm.c b/arch/sandbox/lib/bootm.c
> index d49c927..9ca89b5 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 " PRIpa
> +  ")...\n",
>images