public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] nios2: change size_t to fix format warning for gcc 4.7.3
@ 2013-09-03  2:38 Thomas Chou
  2013-09-03  3:14 ` Thomas Chou
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Chou @ 2013-09-03  2:38 UTC (permalink / raw)
  To: u-boot

The gcc-4.7.3 in lastest nios2 toolchain generated lots of warning on
type mismatch. So change typedef of size_t to unsigned int, followed
those of arm and mips arch.

spi_flash.c: In function 'spi_flash_read_write':
spi_flash.c:42:3: warning: format '%zu' expects argument of type
  'size_t', but argument 2 has type 'long unsigned int' [-Wformat]

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
---
 arch/nios2/include/asm/posix_types.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/nios2/include/asm/posix_types.h b/arch/nios2/include/asm/posix_types.h
index 6733640..b4bf261 100644
--- a/arch/nios2/include/asm/posix_types.h
+++ b/arch/nios2/include/asm/posix_types.h
@@ -16,8 +16,8 @@ typedef int		__kernel_pid_t;
 typedef unsigned short	__kernel_ipc_pid_t;
 typedef unsigned short	__kernel_uid_t;
 typedef unsigned short	__kernel_gid_t;
-typedef unsigned long	__kernel_size_t;
-typedef long		__kernel_ssize_t;
+typedef unsigned int	__kernel_size_t;
+typedef int		__kernel_ssize_t;
 typedef int		__kernel_ptrdiff_t;
 typedef long		__kernel_time_t;
 typedef long		__kernel_suseconds_t;
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH] nios2: change size_t to fix format warning for gcc 4.7.3
  2013-09-03  2:38 [U-Boot] [PATCH] nios2: change size_t to fix format warning for gcc 4.7.3 Thomas Chou
@ 2013-09-03  3:14 ` Thomas Chou
  2013-09-05 12:55   ` Thomas Chou
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Chou @ 2013-09-03  3:14 UTC (permalink / raw)
  To: u-boot

Hi Mike,

On 09/03/2013 10:38 AM, Thomas Chou wrote:
> The gcc-4.7.3 in lastest nios2 toolchain generated lots of warning on
> type mismatch. So change typedef of size_t to unsigned int, followed
> those of arm and mips arch.
>
> spi_flash.c: In function 'spi_flash_read_write':
> spi_flash.c:42:3: warning: format '%zu' expects argument of type
>    'size_t', but argument 2 has type 'long unsigned int' [-Wformat]

I need help on this. I had a similar problem for cmd_sf in 20111214.

This patch works for gcc-4.7.3, but triggers warning for gcc-3.4.6 and 
gcc-4.1.2.


Before,

gcc-3.4.6 and gcc-4.1.2 got no warning.

gcc-4.7.2 got

spi_flash.c: In function 'spi_flash_read_write':
spi_flash.c:42:3: warning: format '%zu' expects argument of type 
'size_t', but argument 2 has type 'long unsigned int' [-Wformat]
spi_flash.c:48:4: warning: format '%zu' expects argument of type 
'size_t', but argument 2 has type 'long unsigned int' [-Wformat]
spi_flash.c: In function 'spi_flash_cmd_write_multi':
spi_flash.c:236:3: warning: format '%zu' expects argument of type 
'size_t', but argument 7 has type 'long unsigned int' [-Wformat]
cmd_nvedit.c: In function 'do_env_export':
cmd_nvedit.c:912:3: warning: format '%zX' expects argument of type 
'size_t', but argument 3 has type 'long unsigned int' [-Wformat]
cmd_nvedit.c: In function 'do_env_import':
cmd_nvedit.c:1029:3: warning: format '%zu' expects argument of type 
'size_t', but argument 2 has type 'long unsigned int' [-Wformat]
cmd_nvedit.c:1029:3: warning: format '%zX' expects argument of type 
'size_t', but argument 3 has type 'long unsigned int' [-Wformat]
cmd_sf.c: In function 'spi_flash_update_block':
cmd_sf.c:153:2: warning: format '%zx' expects argument of type 'size_t', 
but argument 4 has type 'long unsigned int' [-Wformat]
cmd_sf.c:158:3: warning: format '%zx' expects argument of type 'size_t', 
but argument 3 has type 'long unsigned int' [-Wformat]
cmd_sf.c: In function 'spi_flash_update':
cmd_sf.c:206:9: warning: format '%zu' expects argument of type 'size_t', 
but argument 2 has type 'long unsigned int' [-Wformat]
cmd_sf.c:224:9: warning: format '%zu' expects argument of type 'size_t', 
but argument 2 has type 'long unsigned int' [-Wformat]
cmd_sf.c:224:9: warning: format '%zu' expects argument of type 'size_t', 
but argument 3 has type 'long unsigned int' [-Wformat]
cmd_sf.c: In function 'do_spi_flash_read_write':
cmd_sf.c:279:10: warning: format '%zu' expects argument of type 
'size_t', but argument 2 has type 'long unsigned int' [-Wformat]
cmd_sf.c: In function 'do_spi_flash_erase':
cmd_sf.c:314:9: warning: format '%zu' expects argument of type 'size_t', 
but argument 2 has type 'long unsigned int' [-Wformat]
hashtable.c: In function 'hexport_r':
hashtable.c:605:2: warning: format '%zu' expects argument of type 
'size_t', but argument 5 has type 'long unsigned int' [-Wformat]
hashtable.c:661:5: warning: format '%zu' expects argument of type 
'size_t', but argument 2 has type 'long unsigned int' [-Wformat]
hashtable.c:661:5: warning: format '%zu' expects argument of type 
'size_t', but argument 3 has type 'long unsigned int' [-Wformat]
hashtable.c: In function 'himport_r':
hashtable.c:793:3: warning: format '%zu' expects argument of type 
'size_t', but argument 2 has type 'long unsigned int' [-Wformat]


After this patch,

gcc-4.7.2 got no warning,

gcc-3.4.6 and gcc-4.1.2 got warning,

spi_flash.c: In function `spi_flash_read_write':
spi_flash.c:42: warning: long unsigned int format, size_t arg (arg 2)
spi_flash.c:48: warning: long unsigned int format, size_t arg (arg 2)
spi_flash.c: In function `spi_flash_cmd_write_multi':
spi_flash.c:236: warning: long unsigned int format, size_t arg (arg 7)
cmd_nvedit.c: In function `do_env_export':
cmd_nvedit.c:912: warning: size_t format, unsigned int arg (arg 3)
cmd_nvedit.c: In function `do_env_import':
cmd_nvedit.c:1029: warning: long unsigned int format, size_t arg (arg 2)
cmd_nvedit.c:1029: warning: long unsigned int format, size_t arg (arg 3)
cmd_sf.c: In function `spi_flash_update_block':
cmd_sf.c:153: warning: long unsigned int format, size_t arg (arg 4)
cmd_sf.c:158: warning: long unsigned int format, size_t arg (arg 3)
cmd_sf.c: In function `spi_flash_update':
cmd_sf.c:224: warning: long unsigned int format, size_t arg (arg 2)
cmd_sf.c:224: warning: long unsigned int format, size_t arg (arg 3)
cmd_sf.c: In function `do_spi_flash_read_write':
cmd_sf.c:279: warning: size_t format, unsigned int arg (arg 2)
cmd_sf.c: In function `do_spi_flash_erase':
cmd_sf.c:314: warning: size_t format, unsigned int arg (arg 2)
hashtable.c: In function `hexport_r':
hashtable.c:605: warning: long unsigned int format, size_t arg (arg 5)
hashtable.c:661: warning: long unsigned int format, size_t arg (arg 2)
hashtable.c:661: warning: long unsigned int format, size_t arg (arg 3)
hashtable.c: In function `himport_r':
hashtable.c:793: warning: long unsigned int format, size_t arg (arg 2)

Any comments welcome.

Thomas Chou

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH] nios2: change size_t to fix format warning for gcc 4.7.3
  2013-09-03  3:14 ` Thomas Chou
@ 2013-09-05 12:55   ` Thomas Chou
  2013-09-05 12:56     ` Tom Rini
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Chou @ 2013-09-05 12:55 UTC (permalink / raw)
  To: u-boot

I have checked with Altera. This is a toolchain change. We will keep 
this and follow mostly the types in 
linux-2.6/include/uapi/asm-generic/posix_types.h .

- Thomas

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH] nios2: change size_t to fix format warning for gcc 4.7.3
  2013-09-05 12:55   ` Thomas Chou
@ 2013-09-05 12:56     ` Tom Rini
  0 siblings, 0 replies; 4+ messages in thread
From: Tom Rini @ 2013-09-05 12:56 UTC (permalink / raw)
  To: u-boot

On Thu, Sep 05, 2013 at 08:55:09PM +0800, Thomas Chou wrote:

> I have checked with Altera. This is a toolchain change. We will keep
> this and follow mostly the types in
> linux-2.6/include/uapi/asm-generic/posix_types.h .

For clarity, this patch should be...  Thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130905/bb02ec57/attachment.pgp>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-09-05 12:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-03  2:38 [U-Boot] [PATCH] nios2: change size_t to fix format warning for gcc 4.7.3 Thomas Chou
2013-09-03  3:14 ` Thomas Chou
2013-09-05 12:55   ` Thomas Chou
2013-09-05 12:56     ` Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox