Stefan Reinauer ([email protected]) just uploaded a new patch set to 
gerrit, which you can find at http://review.coreboot.org/2653

-gerrit

commit 67602843f673307645a4e5b39772e00548e14c86
Author: Gabe Black <[email protected]>
Date:   Tue Jan 15 16:22:04 2013 -0800

    libpayload: In the USBMSC read_capacity function, make buf an array of u32.
    
    That way when it's treated as a u32 when its value is extracted for 
numblocks
    and blocksize below, it doesn't make the compiler unhappy, and it ensures 
that
    the buffer will be properly aligned on architectures where that sort of 
thing
    matters.
    
    Built and saw warnings about type punning go away.
    
    Change-Id: I254e0b5e70847112d660675b7df0ac9cb52e4051
    Signed-off-by: Gabe Black <[email protected]>
---
 payloads/libpayload/drivers/usb/usbmsc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/payloads/libpayload/drivers/usb/usbmsc.c 
b/payloads/libpayload/drivers/usb/usbmsc.c
index 0032f58..16af448 100644
--- a/payloads/libpayload/drivers/usb/usbmsc.c
+++ b/payloads/libpayload/drivers/usb/usbmsc.c
@@ -375,14 +375,14 @@ read_capacity (usbdev_t *dev)
        cmdblock_t cb;
        memset (&cb, 0, sizeof (cb));
        cb.command = 0x25;      // read capacity
-       u8 buf[8];
+       u32 buf[2];
 
        usb_debug ("Reading capacity of mass storage device.\n");
        int count = 0, ret;
        while (count++ < 20) {
                switch (ret = execute_command
                                (dev, cbw_direction_data_in, (u8 *) &cb,
-                                sizeof (cb), buf, 8, 0)) {
+                                sizeof (cb), (u8 *)buf, 8, 0)) {
                case MSC_COMMAND_OK:
                        break;
                case MSC_COMMAND_FAIL:
@@ -398,8 +398,8 @@ read_capacity (usbdev_t *dev)
                MSC_INST (dev)->numblocks = 0xffffffff;
                MSC_INST (dev)->blocksize = 512;
        } else {
-               MSC_INST (dev)->numblocks = ntohl (*(u32 *) buf) + 1;
-               MSC_INST (dev)->blocksize = ntohl (*(u32 *) (buf + 4));
+               MSC_INST (dev)->numblocks = ntohl(buf[0]) + 1;
+               MSC_INST (dev)->blocksize = ntohl(buf[1]);
        }
        usb_debug ("  %d %d-byte sectors (%d MB)\n", MSC_INST (dev)->numblocks,
                MSC_INST (dev)->blocksize,

-- 
coreboot mailing list: [email protected]
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to