[U-Boot] m68k: Fix warnings with gcc 4.6

Masahiro Yamada yamada.m at jp.panasonic.com
Tue Jun 17 10:34:48 CEST 2014


Hi Simon,


On Wed, 11 Jun 2014 18:19:28 -0400
Tom Rini <trini at ti.com> wrote:

> On Sat, Jun 07, 2014 at 10:07:58PM -0600, Simon Glass wrote:
> 
> > Most of the warnings seem to be related to using 'int' for size_t. Change
> > this and fix up the remaining warnings and problems. For bootm, the warning
> > was masked by others, and there is an actual bug in the code.
> > 
> > Signed-off-by: Simon Glass <sjg at chromium.org>
> 
> Applied to u-boot/master, thanks!
> 
> -- 
> Tom



Since commit ddc94378d, I see lots of warnings when compiling m68k boards like this:




Configuring for M52277EVB - Board: M52277EVB, Options: SYS_SPANSION_BOOT,SYS_TEXT_BASE=0x00000000
   text	   data	    bss	    dec	    hex	filename
 117375	  11530	   4092	 132997	  20785	./u-boot
common/cli_simple.c: In function 'process_macros':
common/cli_simple.c:73:2: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type '__kernel_size_t' [-Wformat]
common/cli_simple.c:162:2: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type '__kernel_size_t' [-Wformat]
drivers/mtd/spi/sf.c: In function 'spi_flash_read_write':
drivers/mtd/spi/sf.c:30:3: warning: format '%zu' expects argument of type 'size_t', but argument 2 has type 'long unsigned int' [-Wformat]
drivers/mtd/spi/sf.c:36:4: warning: format '%zu' expects argument of type 'size_t', but argument 2 has type 'long unsigned int' [-Wformat]
drivers/mtd/spi/sf_ops.c: In function 'spi_flash_cmd_write_ops':
drivers/mtd/spi/sf_ops.c:323:3: warning: format '%zu' expects argument of type 'size_t', but argument 7 has type 'long unsigned int' [-Wformat]
common/cmd_sf.c: In function 'spi_flash_update_block':
common/cmd_sf.c:154:2: warning: format '%zx' expects argument of type 'size_t', but argument 4 has type 'long unsigned int' [-Wformat]
common/cmd_sf.c:161:3: warning: format '%zx' expects argument of type 'size_t', but argument 3 has type 'long unsigned int' [-Wformat]
common/cmd_sf.c: In function 'spi_flash_update':
common/cmd_sf.c:218:9: warning: format '%zu' expects argument of type 'size_t', but argument 2 has type 'long unsigned int' [-Wformat]
common/cmd_sf.c:236:9: warning: format '%zu' expects argument of type 'size_t', but argument 2 has type 'long unsigned int' [-Wformat]
common/cmd_sf.c:236:9: warning: format '%zu' expects argument of type 'size_t', but argument 3 has type 'long unsigned int' [-Wformat]
common/cmd_sf.c: In function 'do_spi_flash_read_write':
common/cmd_sf.c:291:10: warning: format '%zu' expects argument of type 'size_t', but argument 2 has type 'long unsigned int' [-Wformat]
common/cmd_sf.c: In function 'do_spi_flash_erase':
common/cmd_sf.c:326:9: warning: format '%zu' expects argument of type 'size_t', but argument 2 has type 'long unsigned int' [-Wformat]
common/cmd_nvedit.c: In function 'do_env_export':
common/cmd_nvedit.c:914:3: warning: format '%zX' expects argument of type 'size_t', but argument 3 has type 'long unsigned int' [-Wformat]
common/cmd_nvedit.c: In function 'do_env_import':
common/cmd_nvedit.c:1036:3: warning: format '%zu' expects argument of type 'size_t', but argument 2 has type 'long unsigned int' [-Wformat]
common/cmd_nvedit.c:1036:3: warning: format '%zX' expects argument of type 'size_t', but argument 3 has type 'long unsigned int' [-Wformat]
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]


Reverting the following fixes the warnings.

 --- a/arch/m68k/include/asm/posix_types.h
 +++ b/arch/m68k/include/asm/posix_types.h
 @@ -15,7 +15,7 @@ typedef long          __kernel_off_t;
  typedef int            __kernel_pid_t;
  typedef unsigned int   __kernel_uid_t;
  typedef unsigned int   __kernel_gid_t;
 -typedef unsigned int   __kernel_size_t;
 +typedef unsigned long  __kernel_size_t;
  typedef int            __kernel_ssize_t;
  typedef long           __kernel_ptrdiff_t;
  typedef long           __kernel_time_t;



In m68k Linux,  __kernel_size_t is set to unsigned int.

So I am not sure if your change is good.
(At least for me, it worsens the situation.)

Does it depend on each tool-chain ?


My tool-chain is like this:

$ m68k-linux-gcc -v
Using built-in specs.
COLLECT_GCC=m68k-linux-gcc
COLLECT_LTO_WRAPPER=/opt/gcc-4.6.3-nolibc/m68k-linux/bin/../libexec/gcc/m68k-linux/4.6.3/lto-wrapper
Target: m68k-linux
Configured with: /home/tony/buildall/src/gcc/configure --target=m68k-linux --host=x86_64-linux-gnu --build=x86_64-linux-gnu --enable-targets=all --prefix=/opt/cross/gcc-4.6.3-nolibc/m68k-linux/ --enable-languages=c --with-newlib --without-headers --enable-sjlj-exceptions --with-system-libunwind --disable-nls --disable-threads --disable-shared --disable-libmudflap --disable-libssp --disable-libgomp --disable-decimal-float --enable-checking=release --with-mpfr=/home/tony/buildall/src/sys-x86_64 --with-gmp=/home/tony/buildall/src/sys-x86_64 --disable-bootstrap --disable-libquadmath
Thread model: single
gcc version 4.6.3 (GCC)



Best Regards
Masahiro Yamada



More information about the U-Boot mailing list