]> git.sur5r.net Git - openocd/commitdiff
stlink: fix alignment build warning
authorAlexandre Pereira da Silva <aletes.xgr@gmail.com>
Fri, 24 Feb 2012 20:51:48 +0000 (18:51 -0200)
committerSpencer Oliver <spen@spen-soft.co.uk>
Wed, 14 Mar 2012 22:23:43 +0000 (22:23 +0000)
The {read,write}_mem32 interface functions was asking a 32 bits buffer
but they don't need 32 bits alignment.
This will change the interface to a 8 bits buffer to remove the
alignment mismatch warning. This was causing build errors on platforms
with strict aliasing rules.

Change-Id: I338be8df5686f07a64ddb4f17c1bb494af583999
Signed-off-by: Alexandre Pereira da Silva <aletes.xgr@gmail.com>
Reviewed-on: http://openocd.zylin.com/483
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
src/jtag/drivers/stlink_usb.c
src/jtag/stlink/stlink_layout.h
src/target/stm32_stlink.c

index 98eeb09029d8de9584097a3ab60935d34c4704d6..331264244a1dadb66b011902230505e896d90f28 100644 (file)
@@ -926,7 +926,7 @@ static int stlink_usb_write_mem8(void *handle, uint32_t addr, uint16_t len,
        h_u16_to_le(h->cmdbuf+h->cmdidx, len);
        h->cmdidx += 2;
 
-       res = stlink_usb_xfer(handle, (uint8_t *) buffer, len);
+       res = stlink_usb_xfer(handle, buffer, len);
 
        if (res != ERROR_OK)
                return res;
@@ -936,7 +936,7 @@ static int stlink_usb_write_mem8(void *handle, uint32_t addr, uint16_t len,
 
 /** */
 static int stlink_usb_read_mem32(void *handle, uint32_t addr, uint16_t len,
-                         uint32_t *buffer)
+                         uint8_t *buffer)
 {
        int res;
        struct stlink_usb_handle_s *h;
@@ -968,7 +968,7 @@ static int stlink_usb_read_mem32(void *handle, uint32_t addr, uint16_t len,
 
 /** */
 static int stlink_usb_write_mem32(void *handle, uint32_t addr, uint16_t len,
-                          const uint32_t *buffer)
+                          const uint8_t *buffer)
 {
        int res;
        struct stlink_usb_handle_s *h;
@@ -988,7 +988,7 @@ static int stlink_usb_write_mem32(void *handle, uint32_t addr, uint16_t len,
        h_u16_to_le(h->cmdbuf+h->cmdidx, len);
        h->cmdidx += 2;
 
-       res = stlink_usb_xfer(handle, (uint8_t *) buffer, len);
+       res = stlink_usb_xfer(handle, buffer, len);
 
        if (res != ERROR_OK)
                return res;
index c0c89f57076b7f1d4ea199c0b7070d84094efc88..59e6174cf90b6d142172320624f053a710f5e3b2 100644 (file)
@@ -56,10 +56,10 @@ struct stlink_layout_api_s {
                            const uint8_t *buffer);
        /** */
        int (*read_mem32) (void *handle, uint32_t addr, uint16_t len,
-                          uint32_t *buffer);
+                          uint8_t *buffer);
        /** */
        int (*write_mem32) (void *handle, uint32_t addr, uint16_t len,
-                           const uint32_t *buffer);
+                           const uint8_t *buffer);
        /** */
        int (*idcode) (void *fd, uint32_t *idcode);
        /** */
index d2f38e5af384d4eb8194977ac01022472baf30ae..7bec73f5827a3ceafcf4d6de109c9a6bd35666a1 100644 (file)
@@ -586,7 +586,6 @@ static int stm32_stlink_read_memory(struct target *target, uint32_t address,
        int res;
        uint32_t buffer_threshold = 128;
        uint32_t addr_increment = 4;
-       uint8_t *dst = buffer;
        uint32_t c;
        struct stlink_interface_s *stlink_if = target_to_stlink(target);
 
@@ -612,16 +611,16 @@ static int stm32_stlink_read_memory(struct target *target, uint32_t address,
 
                if (size != 4)
                        res = stlink_if->layout->api->read_mem8(stlink_if->fd,
-                                       address, c, dst);
+                                       address, c, buffer);
                else
                        res = stlink_if->layout->api->read_mem32(stlink_if->fd,
-                                       address, c, (uint32_t *)dst);
+                                       address, c, buffer);
 
                if (res != ERROR_OK)
                        return res;
 
                address += (c * addr_increment);
-               dst += (c * addr_increment);
+               buffer += (c * addr_increment);
                count -= c;
        }
 
@@ -635,7 +634,6 @@ static int stm32_stlink_write_memory(struct target *target, uint32_t address,
        int res;
        uint32_t buffer_threshold = 128;
        uint32_t addr_increment = 4;
-       const uint8_t *dst = buffer;
        uint32_t c;
        struct stlink_interface_s *stlink_if = target_to_stlink(target);
 
@@ -661,16 +659,16 @@ static int stm32_stlink_write_memory(struct target *target, uint32_t address,
 
                if (size != 4)
                        res = stlink_if->layout->api->write_mem8(stlink_if->fd,
-                                       address, c, dst);
+                                       address, c, buffer);
                else
                        res = stlink_if->layout->api->write_mem32(stlink_if->fd,
-                                       address, c, (uint32_t *)dst);
+                                       address, c, buffer);
 
                if (res != ERROR_OK)
                        return res;
 
                address += (c * addr_increment);
-               dst += (c * addr_increment);
+               buffer += (c * addr_increment);
                count -= c;
        }