All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/9] usb: Fix strict-aliasing warning in host/ohci-hcd.c
Date: Thu,  5 Jan 2012 19:54:49 -0800	[thread overview]
Message-ID: <1325822097-15227-2-git-send-email-sjg@chromium.org> (raw)
In-Reply-To: <1325822097-15227-1-git-send-email-sjg@chromium.org>

This fixes these warnings seen with my gcc 4.6 compiler.

ohci-hcd.c: In function 'submit_control_msg':
ohci-hcd.c:1307: warning: dereferencing pointer 'pretmp.729' does break strict-aliasing rules
cc1: note: initialized from here
ohci-hcd.c:1310: warning: dereferencing pointer 'pretmp.729' does break strict-aliasing rules
cc1: note: initialized from here
ohci-hcd.c:1313: warning: dereferencing pointer 'pretmp.729' does break strict-aliasing rules

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 drivers/usb/host/ohci-hcd.c |   26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c
index cf906b4..2cbb326 100644
--- a/drivers/usb/host/ohci-hcd.c
+++ b/drivers/usb/host/ohci-hcd.c
@@ -1261,20 +1261,18 @@ static int ohci_submit_rh_msg(struct usb_device *dev, unsigned long pipe,
 	int leni = transfer_len;
 	int len = 0;
 	int stat = 0;
-	__u32 datab[4];
+	u8 *dataptr = NULL;
 	union {
-		void *ptr;
-		__u8 *u8;
-		__u16 *u16;
-		__u32 *u32;
+		/* data will be in here when dataptr stays as NULL */
+		__u8 u8[16];
+		__u16 u16[8];
+		__u32 u32[3];
 	} databuf;
 	__u16 bmRType_bReq;
 	__u16 wValue;
 	__u16 wIndex;
 	__u16 wLength;
 
-	databuf.u32 = (__u32 *)datab;
-
 #ifdef DEBUG
 pkt_print(NULL, dev, pipe, buffer, transfer_len,
 	  cmd, "SUB(rh)", usb_pipein(pipe));
@@ -1381,14 +1379,14 @@ pkt_print(NULL, dev, pipe, buffer, transfer_len,
 					min_t(unsigned int,
 					sizeof(root_hub_dev_des),
 					wLength));
-			databuf.ptr = root_hub_dev_des; OK(len);
+			dataptr = root_hub_dev_des; OK(len);
 		case (0x02): /* configuration descriptor */
 			len = min_t(unsigned int,
 					leni,
 					min_t(unsigned int,
 					sizeof(root_hub_config_des),
 					wLength));
-			databuf.ptr = root_hub_config_des; OK(len);
+			dataptr = root_hub_config_des; OK(len);
 		case (0x03): /* string descriptors */
 			if (wValue == 0x0300) {
 				len = min_t(unsigned int,
@@ -1396,7 +1394,7 @@ pkt_print(NULL, dev, pipe, buffer, transfer_len,
 						min_t(unsigned int,
 						sizeof(root_hub_str_index0),
 						wLength));
-				databuf.ptr = root_hub_str_index0;
+				dataptr = root_hub_str_index0;
 				OK(len);
 			}
 			if (wValue == 0x0301) {
@@ -1405,7 +1403,7 @@ pkt_print(NULL, dev, pipe, buffer, transfer_len,
 						min_t(unsigned int,
 						sizeof(root_hub_str_index1),
 						wLength));
-				databuf.ptr = root_hub_str_index1;
+				dataptr = root_hub_str_index1;
 				OK(len);
 		}
 		default:
@@ -1469,8 +1467,10 @@ pkt_print(NULL, dev, pipe, buffer, transfer_len,
 #endif
 
 	len = min_t(int, len, leni);
-	if (data != databuf.ptr)
-		memcpy(data, databuf.ptr, len);
+	if (dataptr)
+		memcpy(data, dataptr, len);
+	else
+		memcpy(data, &databuf, len);
 	dev->act_len = len;
 	dev->status = stat;
 
-- 
1.7.3.1

  reply	other threads:[~2012-01-06  3:54 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-06  3:54 [U-Boot] [PATCH 0/9] Fix a few warnings that bug me Simon Glass
2012-01-06  3:54 ` Simon Glass [this message]
2012-01-08  9:32   ` [U-Boot] [PATCH 1/9] usb: Fix strict-aliasing warning in host/ohci-hcd.c Mike Frysinger
2012-01-08 18:02     ` Simon Glass
2012-01-06  3:54 ` [U-Boot] [PATCH 2/9] Fix strict-aliasing warning in dlmalloc Simon Glass
2012-01-06  6:48   ` Wolfgang Denk
2012-01-06 20:39     ` Simon Glass
2012-01-06 23:37       ` Wolfgang Denk
2012-01-08  0:57         ` Simon Glass
2012-01-08  9:27       ` Mike Frysinger
2012-08-13 15:25   ` Andreas Bießmann
2012-09-04 21:25     ` Andreas Bießmann
2012-01-06  3:54 ` [U-Boot] [PATCH 3/9] mpc5xxx: Fix strict-aliasing warnings in usb_ohci.c Simon Glass
2012-01-06  3:54 ` [U-Boot] [PATCH 4/9] ppc4xx: " Simon Glass
2012-10-16  6:28   ` Marek Vasut
2012-10-16 13:35     ` Simon Glass
2012-01-06  3:54 ` [U-Boot] [PATCH 5/9] sandbox: sort header files in os.c Simon Glass
2012-01-08  8:49   ` Mike Frysinger
2012-01-09 22:17     ` Simon Glass
2012-01-06  3:54 ` [U-Boot] [PATCH 6/9] sandbox: Add required header to os.c Simon Glass
2012-01-08  8:49   ` Mike Frysinger
2012-01-09 22:18     ` Simon Glass
2012-01-06  3:54 ` [U-Boot] [PATCH 7/9] Remove CONFIG_SYS_EXTBDINFO from snapper9260.h Simon Glass
2012-02-22 11:07   ` Stefano Babic
2012-03-27 16:58   ` Anatolij Gustschin
2012-01-06  3:54 ` [U-Boot] [PATCH 8/9] m68k: Change memsz to a signed char to avoid warning Simon Glass
2012-01-08  9:29   ` Mike Frysinger
2012-02-22 12:01   ` Stefano Babic
2012-01-06  3:54 ` [U-Boot] [PATCH 9/9] ppc: Change memsz variable to signed char Simon Glass
2012-01-08  9:29   ` Mike Frysinger
2012-02-22 12:00   ` Stefano Babic
2012-01-06  6:20 ` [U-Boot] [PATCH 0/9] Fix a few warnings that bug me Wolfgang Denk
2012-01-06  6:28   ` Simon Glass
2012-02-20 18:49     ` Simon Glass
2012-02-21 10:20       ` Stefano Babic
2012-02-21 13:49         ` Stefano Babic
2012-02-21 17:06         ` Mike Frysinger
2012-02-21 17:15           ` Stefano Babic
2012-02-21 18:40             ` Simon Glass
2012-02-22  5:35               ` Mike Frysinger
2012-02-22 11:06               ` Stefano Babic
2012-03-03 14:31               ` Wolfgang Denk
2012-03-05 18:22 ` Marek Vasut
2012-03-05 18:33   ` Simon Glass
2012-03-05 18:42     ` Andy Pont
2012-03-05 19:17       ` Wolfgang Denk
2012-03-05 18:46     ` Marek Vasut

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1325822097-15227-2-git-send-email-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.