From 2c2c4fae2221f87aeff88162fa3216f3a91af793 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Tue, 15 Jan 2013 16:22:04 -0800 Subject: 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 Reviewed-on: http://review.coreboot.org/2653 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi Reviewed-by: Paul Menzel --- payloads/libpayload/drivers/usb/usbmsc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'payloads') diff --git a/payloads/libpayload/drivers/usb/usbmsc.c b/payloads/libpayload/drivers/usb/usbmsc.c index 0032f581bb..16af44888e 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, -- cgit v1.2.3