Skip to contentSkip to conversation

common/board_f: implement type casting for gd structure

PATCH In review Alexey Brodkin 3 participants 3 messages Feb 25, 2015 – Mar 6, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 common/board_f: implement type casting for gd structure

In case of global data structure defined as "register volatile" compiler throws an warning about incorrect type used:
--->8---
common/board_f.c: In function "board_init_f_r":
common/board_f.c:1073:2: warning: passing argument 1 of "&board_init_r +(sizetype)gd->reloc_off" discards "volatile" qualifier from pointer target type [enabled by default]
(board_init_r + gd->reloc_off)(gd, gd->relocaddr);
^
common/board_f.c:1073:2: note: expected "struct gd_t *" but argument is of type "volatile struct gd_t *"
--->8---

An obvious fix is manual casting to "gd_t *".

---
 common/board_f.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/board_f.c +1 -1
index a1dcc5f..96a23ae 100644
@@ -1070,7 +1070,7 @@ void board_init_f_r(void)
 	 * Transfer execution from Flash to RAM by calculating the address
 	 * of the in-RAM copy of board_init_r() and calling it
 	 */
-	(board_init_r + gd->reloc_off)(gd, gd->relocaddr);
+	(board_init_r + gd->reloc_off)((gd_t *)gd, gd->relocaddr);
 
 	/* NOTREACHED - board_init_r() does not return */
 	hang();
Signature · 1 line
2.1.0
#1 lore raw

PATCH 1/1 common/board_f: implement type casting for gd structure

Quoted 13 lines · Alexey Brodkin

In case of global data structure defined as "register volatile" compiler throws an warning about incorrect type used:
--->8---
common/board_f.c: In function "board_init_f_r":
common/board_f.c:1073:2: warning: passing argument 1 of "&board_init_r +(sizetype)gd->reloc_off" discards "volatile" qualifier from pointer target type [enabled by default]
(board_init_r + gd->reloc_off)(gd, gd->relocaddr);
^
common/board_f.c:1073:2: note: expected "struct gd_t *" but argument is of type "volatile struct gd_t *"
--->8---

Quoted 9 lines

An obvious fix is manual casting to "gd_t *".

---
 common/board_f.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
#2 lore raw
In reply to Alexey Brodkin
Quoted 13 lines · Alexey Brodkin

In case of global data structure defined as "register volatile" compiler throws an warning about incorrect type used:
--->8---
common/board_f.c: In function "board_init_f_r":
common/board_f.c:1073:2: warning: passing argument 1 of "&board_init_r +(sizetype)gd->reloc_off" discards "volatile" qualifier from pointer target type [enabled by default]
(board_init_r + gd->reloc_off)(gd, gd->relocaddr);
^
common/board_f.c:1073:2: note: expected "struct gd_t *" but argument is of type "volatile struct gd_t *"
--->8---

Quoted 6 lines

An obvious fix is manual casting to "gd_t *".

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150306/3bfee7e2/attachment.sig>