From 61d464bf098c07ed395ae89d3bed6ae2fe2f2085 Mon Sep 17 00:00:00 2001 From: Gareth McMullin Date: Thu, 4 Apr 2013 20:16:13 -0700 Subject: [PATCH] dfu: Fix warnings. --- src/platforms/stm32/dfucore.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/platforms/stm32/dfucore.c b/src/platforms/stm32/dfucore.c index c1d5cfd..2786e9a 100644 --- a/src/platforms/stm32/dfucore.c +++ b/src/platforms/stm32/dfucore.c @@ -121,13 +121,19 @@ static const char *usb_strings[] = { DFU_IFACE_STRING, }; +static u32 get_le32(const void *vp) +{ + const u8 *p = vp; + return ((u32)p[3] << 24) + ((u32)p[2] << 16) + (p[1] << 8) + p[0]; +} + static u8 usbdfu_getstatus(u32 *bwPollTimeout) { switch(usbdfu_state) { case STATE_DFU_DNLOAD_SYNC: usbdfu_state = STATE_DFU_DNBUSY; *bwPollTimeout = dfu_poll_timeout(prog.buf[0], - *(u32 *)(prog.buf + 1), + get_le32(prog.buf + 1), prog.blocknum); return DFU_STATUS_OK; @@ -151,7 +157,7 @@ usbdfu_getstatus_complete(usbd_device *dev, struct usb_setup_data *req) flash_unlock(); if(prog.blocknum == 0) { - u32 addr = *(u32 *)(prog.buf + 1); + u32 addr = get_le32(prog.buf + 1); if (addr < APP_ADDRESS || (addr >= max_address)) { flash_lock();