arm_jtag.h: In function `arm7flip32':
arm_jtag.h:64: warning: cast increases required alignment of target type
arm_jtag.h: In function `arm_le_to_h_u32':
arm_jtag.h:70: warning: cast increases required alignment of target type
...
I made 3 patch files, all warnings are same, but way of fixing are different.
patch1: Cast from uint32_t * to uint8_t *.
patch2: use union
patch3: uint8_t * = ulong = uint32_t *
tested with gcc 3.4.5 and 4.4.0.
Hiroshi Ito
Media Lab. Inc.,
URL http://www.mlb.co.jp ( Sorry, Japanese only. )
TEL +81-3-5294-7255 FAX +81-3-5294-7256
Index: src/pld/virtex2.c
===
--- src/pld/virtex2.c (revision 2589)
+++ src/pld/virtex2.c (working copy)
@@ -90,8 +90,8 @@
static __inline__ void virtexflip32(jtag_callback_data_t arg)
{
- uint8_t *in = (uint8_t *)arg;
- *((uint32_t *)in) = flip_u32(le_to_h_u32(in), 32);
+ uint32_t *in = (uint32_t *)arg;
+ *in = flip_u32(le_to_h_u32((uint8_t *)in), 32);
}
static int virtex2_receive_32(struct pld_device_s *pld_device,
Index: src/target/etb.c
===
--- src/target/etb.c(revision 2589)
+++ src/target/etb.c(working copy)
@@ -160,8 +160,8 @@
static void etb_getbuf(jtag_callback_data_t arg)
{
- uint8_t *in = (uint8_t *)arg;
- *((uint32_t *)in) = buf_get_u32(in, 0, 32);
+ uint32_t *in = (uint32_t *)arg;
+ *in = buf_get_u32((uint8_t *)in, 0, 32);
}
Index: src/target/xscale.c
===
--- src/target/xscale.c (revision 2589)
+++ src/target/xscale.c (working copy)
@@ -295,8 +295,8 @@
static void xscale_getbuf(jtag_callback_data_t arg)
{
- uint8_t *in = (uint8_t *)arg;
- *((uint32_t *)in) = buf_get_u32(in, 0, 32);
+ uint32_t *in = (uint32_t *)arg;
+ *in = buf_get_u32((uint8_t *)in, 0, 32);
}
int xscale_receive(target_t *target, uint32_t *buffer, int num_words)
Index: src/target/arm_jtag.h
===
--- src/target/arm_jtag.h (revision 2589)
+++ src/target/arm_jtag.h (working copy)
@@ -60,14 +60,14 @@
/* use this as a static so we can inline it in -O3 and refer to it via a
pointer */
static __inline__ void arm7flip32(jtag_callback_data_t arg)
{
- uint8_t *in = (uint8_t *)arg;
- *((uint32_t *)in) = flip_u32(le_to_h_u32(in), 32);
+ uint32_t *in = (uint32_t *)arg;
+ *in = flip_u32(le_to_h_u32((uint8_t *)in), 32);
}
static __inline__ void arm_le_to_h_u32(jtag_callback_data_t arg)
{
- uint8_t *in = (uint8_t *)arg;
- *((uint32_t *)in) = le_to_h_u32(in);
+ uint32_t *in = (uint32_t *)arg;
+ *in = le_to_h_u32((uint8_t *)in);
}
Index: src/target/arm11.c
===
--- src/target/arm11.c (revision 2589)
+++ src/target/arm11.c (working copy)
@@ -1092,7 +1092,14 @@
*/
int arm11_read_memory(struct target_s *target, uint32_t address, uint32_t
size, uint32_t count, uint8_t *buffer)
{
- /** \todo TODO: check if buffer cast to uint32_t* and uint16_t* might
cause alignment problems */
+
+ /* gcc says, warning: cast increases required alignment of target type
*/
+ /* just make gcc happy */
+ union {
+ uint8_t *bytes;
+ uint32_t *words;
+ } buf;
+ buf.bytes = buffer;
FNC_INFO;
@@ -1128,7 +1135,7 @@
/* MCR p14,0,R1,c0,c5,0 */
arm11_run_instr_data_from_core(arm11, 0xEE001E15, res,
1);
- *buffer++ = res;
+ *buf.bytes++ = res;
}
break;
@@ -1149,7 +1156,7 @@
arm11_run_instr_data_from_core(arm11,
0xEE001E15, res, 1);
uint16_t svalue = res;
- memcpy(buffer + i * sizeof(uint16_t), svalue,
sizeof(uint16_t));
+ memcpy(buf.bytes + i * sizeof(uint16_t),
svalue, sizeof(uint16_t));
}
break;
@@ -1158,12 +1165,10 @@
case 4:
{
uint32_t instr = !arm11_config_memrw_no_increment ? 0xecb05e01
: 0xed905e00;
- /** \todo TODO: buffer cast to uint32_t* causes alignment
warnings */
- uint32_t *words = (uint32_t *)buffer;
/* LDC p14,c5,[R0],#4 */
/* LDC p14,c5,[R0] */
- arm11_run_instr_data_from_core(arm11, instr, words, count);
+ arm11_run_instr_data_from_core(arm11, instr, buf.words, count);
break;
}
}
@@ -1176,6 +1181,13 @@
int arm11_write_memory(struct target_s *target, uint32_t address, uint32_t
size, uint32_t count, uint8_t *buffer)
{
FNC_INFO;
+ /* gcc says, warning: cast increases required