From: Shinya Kuribayashi <skuribay@ruby.dti.ne.jp>
To: u-boot@lists.denx.de
Subject: [U-Boot] MIPS: Fix GCC-4.2 'discards qualifiers from pointer target type' warnings
Date: Sun, 22 Feb 2009 14:24:11 +0900 [thread overview]
Message-ID: <49A0E17B.9090300@ruby.dti.ne.jp> (raw)
In-Reply-To: <200901301122.05028.sr@denx.de>
Compiling dbau1x00 and gth2 boards with GCC-4.2, you would see new warnings
like this:
skuribay at ubuntu:u-boot.git$ ./MAKEALL dbau1000
Configuring for dbau1x00 board...
au1x00_eth.c: In function 'au1x00_send':
au1x00_eth.c:158: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target type
au1x00_eth.c: In function 'au1x00_recv':
au1x00_eth.c:211: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target type
au1x00_eth.c: In function 'au1x00_init':
au1x00_eth.c:252: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target type
au1x00_eth.c: In function 'au1x00_recv':
au1x00_eth.c:211: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target type
au1x00_eth.c: In function 'au1x00_init':
au1x00_eth.c:252: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target type
au1x00_eth.c: In function 'au1x00_send':
au1x00_eth.c:158: warning: passing argument 1 of 'virt_to_phys' discards qualifiers from pointer target type
We're passing a volatile pointer to a function which is expecting a non-
volatile pointer. That's potentially dangerous, so gcc warns about it.
Confirmed with ELDK 4.2 (GCC 4.2.2) and Sourcey G++ 4.2 (GCC 4.2.3).
To fix this, we add a volatile attribute to the argument in question.
The virt_to_phys function in Linux kernel also does the same thing.
Signed-off-by: Stefan Roese <sr@denx.de>
Signed-off-by: Shinya Kuribayashi <skuribay@ruby.dti.ne.jp>
---
Sorry for late reply,
Stefan: I think this is a reasonable fix. I believe this works for ELDK
as well, of course.
Walfgang: Please pick this up directly, thanks in advance.
include/asm-mips/io.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/include/asm-mips/io.h b/include/asm-mips/io.h
index 031186d..025012a 100644
--- a/include/asm-mips/io.h
+++ b/include/asm-mips/io.h
@@ -118,7 +118,7 @@ static inline void set_io_port_base(unsigned long base)
* Change virtual addresses to physical addresses and vv.
* These are trivial on the 1:1 Linux/MIPS mapping
*/
-extern inline phys_addr_t virt_to_phys(void * address)
+extern inline phys_addr_t virt_to_phys(volatile void * address)
{
return CPHYSADDR(address);
}
next prev parent reply other threads:[~2009-02-22 5:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-28 5:44 [U-Boot] [PATCH] MIPS: Fix compile warning in au1x00_eth.c Stefan Roese
2009-01-28 14:39 ` Shinya Kuribayashi
2009-01-28 16:37 ` Stefan Roese
2009-01-30 0:27 ` Shinya Kuribayashi
2009-01-30 10:22 ` Stefan Roese
2009-02-22 5:24 ` Shinya Kuribayashi [this message]
2009-02-22 20:16 ` [U-Boot] MIPS: Fix GCC-4.2 'discards qualifiers from pointer target type' warnings Wolfgang Denk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49A0E17B.9090300@ruby.dti.ne.jp \
--to=skuribay@ruby.dti.ne.jp \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox