diff mbox

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

Message ID 1402200478-14055-1-git-send-email-sjg@chromium.org
State Accepted
Delegated to: Tom Rini
Headers show

Commit Message

Simon Glass June 8, 2014, 4:07 a.m. UTC
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@chromium.org>
---

 arch/m68k/cpu/mcf532x/cpu_init.c    | 2 +-
 arch/m68k/include/asm/posix_types.h | 2 +-
 arch/m68k/lib/bootm.c               | 7 ++-----
 board/astro/mcf5373l/fpga.c         | 2 +-
 board/astro/mcf5373l/mcf5373l.c     | 2 +-
 drivers/fpga/altera.c               | 6 +++---
 drivers/fpga/xilinx.c               | 6 +++---
 7 files changed, 12 insertions(+), 15 deletions(-)

Comments

Tom Rini June 11, 2014, 10:19 p.m. UTC | #1
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@chromium.org>

Applied to u-boot/master, thanks!
Masahiro Yamada June 17, 2014, 8:34 a.m. UTC | #2
Hi Simon,


On Wed, 11 Jun 2014 18:19:28 -0400
Tom Rini <trini@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@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
Simon Glass June 18, 2014, 3:52 a.m. UTC | #3
Hi Masahiro,

On 17 June 2014 01:34, Masahiro Yamada <yamada.m@jp.panasonic.com> wrote:
> Hi Simon,
>
>
> On Wed, 11 Jun 2014 18:19:28 -0400
> Tom Rini <trini@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@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)

That is very unfortunately. I've had m68k warnings forever and I
finally got sick of them and built a new toolchain. Mine is:

/opt/m68k/bin/m68k-elf-gcc -v
Using built-in specs.
COLLECT_GCC=/opt/m68k/bin/m68k-elf-gcc
COLLECT_LTO_WRAPPER=/opt/m68k/libexec/gcc/m68k-elf/4.6.2/lto-wrapper
Target: m68k-elf
Configured with: ../configure --target=m68k-elf --prefix=/opt/m68k/
--enable-languages=c --with-newlib --disable-libmudflap
--disable-libssp --disable-libgomp --disable-libstdcxx-pch
--disable-threads --with-gnu-as --with-gnu-ld --disable-nls
--with-headers=yes --disable-checking --without-headers
Thread model: single

What to do? Is there any way to remove all warnings from m68k without
creating others in other toolchain versions?

Regards,
Simon
Tom Rini June 18, 2014, 5:53 p.m. UTC | #4
On Tue, Jun 17, 2014 at 08:52:09PM -0700, Simon Glass wrote:
> Hi Masahiro,
> 
> On 17 June 2014 01:34, Masahiro Yamada <yamada.m@jp.panasonic.com> wrote:
> > Hi Simon,
> >
> >
> > On Wed, 11 Jun 2014 18:19:28 -0400
> > Tom Rini <trini@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@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)
> 
> That is very unfortunately. I've had m68k warnings forever and I
> finally got sick of them and built a new toolchain. Mine is:
> 
> /opt/m68k/bin/m68k-elf-gcc -v
> Using built-in specs.
> COLLECT_GCC=/opt/m68k/bin/m68k-elf-gcc
> COLLECT_LTO_WRAPPER=/opt/m68k/libexec/gcc/m68k-elf/4.6.2/lto-wrapper
> Target: m68k-elf
> Configured with: ../configure --target=m68k-elf --prefix=/opt/m68k/
> --enable-languages=c --with-newlib --disable-libmudflap
> --disable-libssp --disable-libgomp --disable-libstdcxx-pch
> --disable-threads --with-gnu-as --with-gnu-ld --disable-nls
> --with-headers=yes --disable-checking --without-headers
> Thread model: single
> 
> What to do? Is there any way to remove all warnings from m68k without
> creating others in other toolchain versions?

Ug.  I think in general the answer is yes.  Only sparc is so old that
we'd have to start doing pretty ugly things to avoid a warning
(disk/part.c:453 hwpart might be used uninitalized, but it will always
be set, based on manual inspection).
Simon Glass June 19, 2014, 11:33 p.m. UTC | #5
Hi Tom,

On 18 June 2014 11:53, Tom Rini <trini@ti.com> wrote:
> On Tue, Jun 17, 2014 at 08:52:09PM -0700, Simon Glass wrote:
>> Hi Masahiro,
>>
>> On 17 June 2014 01:34, Masahiro Yamada <yamada.m@jp.panasonic.com> wrote:
>> > Hi Simon,
>> >
>> >
>> > On Wed, 11 Jun 2014 18:19:28 -0400
>> > Tom Rini <trini@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@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)
>>
>> That is very unfortunately. I've had m68k warnings forever and I
>> finally got sick of them and built a new toolchain. Mine is:
>>
>> /opt/m68k/bin/m68k-elf-gcc -v
>> Using built-in specs.
>> COLLECT_GCC=/opt/m68k/bin/m68k-elf-gcc
>> COLLECT_LTO_WRAPPER=/opt/m68k/libexec/gcc/m68k-elf/4.6.2/lto-wrapper
>> Target: m68k-elf
>> Configured with: ../configure --target=m68k-elf --prefix=/opt/m68k/
>> --enable-languages=c --with-newlib --disable-libmudflap
>> --disable-libssp --disable-libgomp --disable-libstdcxx-pch
>> --disable-threads --with-gnu-as --with-gnu-ld --disable-nls
>> --with-headers=yes --disable-checking --without-headers
>> Thread model: single
>>
>> What to do? Is there any way to remove all warnings from m68k without
>> creating others in other toolchain versions?
>
> Ug.  I think in general the answer is yes.  Only sparc is so old that
> we'd have to start doing pretty ugly things to avoid a warning
> (disk/part.c:453 hwpart might be used uninitalized, but it will always
> be set, based on manual inspection).

Well at present even with my patch I get link errors, so I haven't
fully solved the problem every for myself. It is just annoying to
always get failures - it would be great if we could resolved these
fully.

Anyway if my patch makes things worse on other tool chains, then
perhaps we should revert it? Particular if Masahiro has a patch which
corrects the problems (or a toolchain that actually builds).

Regards,
Simon
Tom Rini June 20, 2014, 3:45 p.m. UTC | #6
On Thu, Jun 19, 2014 at 05:33:44PM -0600, Simon Glass wrote:
> Hi Tom,
> 
> On 18 June 2014 11:53, Tom Rini <trini@ti.com> wrote:
> > On Tue, Jun 17, 2014 at 08:52:09PM -0700, Simon Glass wrote:
> >> Hi Masahiro,
> >>
> >> On 17 June 2014 01:34, Masahiro Yamada <yamada.m@jp.panasonic.com> wrote:
> >> > Hi Simon,
> >> >
> >> >
> >> > On Wed, 11 Jun 2014 18:19:28 -0400
> >> > Tom Rini <trini@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@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)
> >>
> >> That is very unfortunately. I've had m68k warnings forever and I
> >> finally got sick of them and built a new toolchain. Mine is:
> >>
> >> /opt/m68k/bin/m68k-elf-gcc -v
> >> Using built-in specs.
> >> COLLECT_GCC=/opt/m68k/bin/m68k-elf-gcc
> >> COLLECT_LTO_WRAPPER=/opt/m68k/libexec/gcc/m68k-elf/4.6.2/lto-wrapper
> >> Target: m68k-elf
> >> Configured with: ../configure --target=m68k-elf --prefix=/opt/m68k/
> >> --enable-languages=c --with-newlib --disable-libmudflap
> >> --disable-libssp --disable-libgomp --disable-libstdcxx-pch
> >> --disable-threads --with-gnu-as --with-gnu-ld --disable-nls
> >> --with-headers=yes --disable-checking --without-headers
> >> Thread model: single
> >>
> >> What to do? Is there any way to remove all warnings from m68k without
> >> creating others in other toolchain versions?
> >
> > Ug.  I think in general the answer is yes.  Only sparc is so old that
> > we'd have to start doing pretty ugly things to avoid a warning
> > (disk/part.c:453 hwpart might be used uninitalized, but it will always
> > be set, based on manual inspection).
> 
> Well at present even with my patch I get link errors, so I haven't
> fully solved the problem every for myself. It is just annoying to
> always get failures - it would be great if we could resolved these
> fully.
> 
> Anyway if my patch makes things worse on other tool chains, then
> perhaps we should revert it? Particular if Masahiro has a patch which
> corrects the problems (or a toolchain that actually builds).

Well, lets cycle back and see if we can get some answers, before we need
to start taking some more drastic action perhaps.  Jason, is there a
toolchain for which MAKEALL -a m68k works?  If not, do we need to start
removing some no longer used / maintained boards?  Thanks!
Simon Glass July 7, 2014, 10:59 p.m. UTC | #7
Hi Jason,

On 24 June 2014 07:06, Jason.Jin@freescale.com <Jason.Jin@freescale.com> wrote:

[snip]

>
>> -----Original Message-----
>> From: Tom Rini [mailto:tom.rini@gmail.com] On Behalf Of Tom Rini

>> Well, lets cycle back and see if we can get some answers, before we need
>> to start taking some more drastic action perhaps.  Jason, is there a
>> toolchain for which MAKEALL -a m68k works?  If not, do we need to start
>> removing some no longer used / maintained boards?  Thanks!
> It's not relate to the used or no longer used boards. For ColdFire with MMU
>  and non-MMU part, we need two different toolchain, so currently we cannot
> use MAKEALL -a m68k to build all the ColdFire boards. Thanks.
>
> Jason
>

Thank seems a bit unfortunate. I wonder if there is a way to
distinguish the two boards from their boards.cfg entry? We could
perhaps add a feature to buildman to support building the same arch
with two different toolchains if that is what it takes?

Also, can you please send a link so I can download the two toolchains?

Regards,
Simon
diff mbox

Patch

diff --git a/arch/m68k/cpu/mcf532x/cpu_init.c b/arch/m68k/cpu/mcf532x/cpu_init.c
index db7ded4..8d01f5f 100644
--- a/arch/m68k/cpu/mcf532x/cpu_init.c
+++ b/arch/m68k/cpu/mcf532x/cpu_init.c
@@ -208,10 +208,10 @@  void cpu_init_f(void)
 	scm2_t *scm2 = (scm2_t *) MMAP_SCM2;
 	gpio_t *gpio = (gpio_t *) MMAP_GPIO;
 	fbcs_t *fbcs = (fbcs_t *) MMAP_FBCS;
+#ifndef CONFIG_WATCHDOG
 	wdog_t *wdog = (wdog_t *) MMAP_WDOG;
 
 	/* watchdog is enabled by default - disable the watchdog */
-#ifndef CONFIG_WATCHDOG
 	out_be16(&wdog->cr, 0);
 #endif
 
diff --git a/arch/m68k/include/asm/posix_types.h b/arch/m68k/include/asm/posix_types.h
index 4fbc040..b97d267 100644
--- 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;
diff --git a/arch/m68k/lib/bootm.c b/arch/m68k/lib/bootm.c
index 804e01d..fa9c493 100644
--- a/arch/m68k/lib/bootm.c
+++ b/arch/m68k/lib/bootm.c
@@ -50,11 +50,7 @@  void arch_lmb_reserve(struct lmb *lmb)
 
 int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *images)
 {
-	ulong rd_len;
-	ulong initrd_start, initrd_end;
 	int ret;
-
-	ulong cmd_start, cmd_end;
 	bd_t  *kbd;
 	void  (*kernel) (bd_t *, ulong, ulong, ulong, ulong);
 	struct lmb *lmb = &images->lmb;
@@ -96,7 +92,8 @@  int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *ima
 	 *   sp+16: Start of command line string
 	 *   sp+20: End   of command line string
 	 */
-	(*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end);
+	(*kernel)(kbd, images->initrd_start, images->initrd_end,
+		  images->cmdline_start, images->cmdline_end);
 	/* does not return */
 error:
 	return 1;
diff --git a/board/astro/mcf5373l/fpga.c b/board/astro/mcf5373l/fpga.c
index 1d044d9..d1110df 100644
--- a/board/astro/mcf5373l/fpga.c
+++ b/board/astro/mcf5373l/fpga.c
@@ -100,7 +100,7 @@  int altera_done_fn(int cookie)
  * writing the complete buffer in one function is much faster,
  * then calling it for every bit
  */
-int altera_write_fn(void *buf, size_t len, int flush, int cookie)
+int altera_write_fn(const void *buf, size_t len, int flush, int cookie)
 {
 	size_t bytecount = 0;
 	gpio_t *gpiop = (gpio_t *)MMAP_GPIO;
diff --git a/board/astro/mcf5373l/mcf5373l.c b/board/astro/mcf5373l/mcf5373l.c
index daba32c..7ec7cb3 100644
--- a/board/astro/mcf5373l/mcf5373l.c
+++ b/board/astro/mcf5373l/mcf5373l.c
@@ -79,7 +79,7 @@  phys_size_t initdram(int board_type)
 	 * (Do not rely on the SDCS register(s) being set to 0x00000000
 	 * during reset as stated in the data sheet.)
 	 */
-	return get_ram_size((unsigned long *)CONFIG_SYS_SDRAM_BASE,
+	return get_ram_size((long *)CONFIG_SYS_SDRAM_BASE,
 				0x80000000 - CONFIG_SYS_SDRAM_BASE);
 }
 
diff --git a/drivers/fpga/altera.c b/drivers/fpga/altera.c
index af189f4..6e34a8e 100644
--- a/drivers/fpga/altera.c
+++ b/drivers/fpga/altera.c
@@ -153,9 +153,9 @@  int altera_info( Altera_desc *desc )
 			printf ("Unsupported interface type, %d\n", desc->iface);
 		}
 
-		printf ("Device Size:   \t%d bytes\n"
-				"Cookie:        \t0x%x (%d)\n",
-				desc->size, desc->cookie, desc->cookie);
+		printf("Device Size:   \t%zd bytes\n"
+		      "Cookie:        \t0x%x (%d)\n",
+		      desc->size, desc->cookie, desc->cookie);
 
 		if (desc->iface_fns) {
 			printf ("Device Function Table @ 0x%p\n", desc->iface_fns);
diff --git a/drivers/fpga/xilinx.c b/drivers/fpga/xilinx.c
index 3795c1a..adb4b8c 100644
--- a/drivers/fpga/xilinx.c
+++ b/drivers/fpga/xilinx.c
@@ -220,9 +220,9 @@  int xilinx_info(xilinx_desc *desc)
 			printf ("Unsupported interface type, %d\n", desc->iface);
 		}
 
-		printf ("Device Size:   \t%d bytes\n"
-				"Cookie:        \t0x%x (%d)\n",
-				desc->size, desc->cookie, desc->cookie);
+		printf("Device Size:   \t%zd bytes\n"
+		       "Cookie:        \t0x%x (%d)\n",
+		       desc->size, desc->cookie, desc->cookie);
 		if (desc->name)
 			printf("Device name:   \t%s\n", desc->name);