From patchwork Wed Dec 7 22:19:28 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfgang Denk X-Patchwork-Id: 130064 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id A26E41007D5 for ; Thu, 8 Dec 2011 09:19:46 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id F192628091; Wed, 7 Dec 2011 23:19:44 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9A7HhtH+7+zm; Wed, 7 Dec 2011 23:19:44 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 41EE0280CB; Wed, 7 Dec 2011 23:19:38 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9CC72280B3 for ; Wed, 7 Dec 2011 23:19:36 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wjO1IDqsg+np for ; Wed, 7 Dec 2011 23:19:36 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.10]) by theia.denx.de (Postfix) with ESMTP id 2AC95280CB for ; Wed, 7 Dec 2011 23:19:34 +0100 (CET) Received: from frontend1.mail.m-online.net (frontend1.mail.intern.m-online.net [192.168.8.180]) by mail-out.m-online.net (Postfix) with ESMTP id 1B66F186DEE5 for ; Wed, 7 Dec 2011 23:19:34 +0100 (CET) X-Auth-Info: BQy12rnRpBBt7Zzfn3m9qci96NDos9+s401ilyAa56s= Received: from diddl.denx.de (host-80-81-18-216.customer.m-online.net [80.81.18.216]) by smtp-auth.mnet-online.de (Postfix) with ESMTPA id 397001C000A2 for ; Wed, 7 Dec 2011 23:19:34 +0100 (CET) Received: from gemini.denx.de (unknown [10.0.0.2]) by diddl.denx.de (Postfix) with ESMTP id DEC981A3768 for ; Wed, 7 Dec 2011 23:19:32 +0100 (CET) Received: by gemini.denx.de (Postfix, from userid 500) id 70F1C1ECC5F; Wed, 7 Dec 2011 23:19:32 +0100 (CET) From: Wolfgang Denk To: u-boot@lists.denx.de Date: Wed, 7 Dec 2011 23:19:28 +0100 Message-Id: <1323296368-26162-10-git-send-email-wd@denx.de> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1323296368-26162-1-git-send-email-wd@denx.de> References: <1323296368-26162-1-git-send-email-wd@denx.de> Subject: [U-Boot] [PATCH 9/9] board/w7o/vpd.c: Fix GCC 4.6 compile warnings X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Fix: vpd.c: In function 'vpd_is_valid': vpd.c:168:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] vpd.c:169:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] vpd.c:178:2: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] vpd.c: In function 'vpd_get_data': vpd.c:281:6: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] vpd.c:291:6: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] vpd.c:297:6: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] vpd.c:302:6: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing] Signed-off-by: Wolfgang Denk --- board/w7o/vpd.c | 26 +++++++++++++++----------- 1 files changed, 15 insertions(+), 11 deletions(-) diff --git a/board/w7o/vpd.c b/board/w7o/vpd.c index d248c97..ba46d71 100644 --- a/board/w7o/vpd.c +++ b/board/w7o/vpd.c @@ -165,8 +165,8 @@ static int vpd_is_valid(unsigned dev_addr, unsigned char *buf) printf("Error: VPD EEPROM 0x%x missing CRC\n", dev_addr); return 0; } - stored_crc16 = *((ushort *) packet->data); - *(ushort *) packet->data = 0; + memcpy(&stored_crc16, packet->data, sizeof(ushort)); + memset(packet->data, 0, sizeof(ushort)); /* OK, lets calculate the CRC and check it */ #if defined(VXWORKS) @@ -175,7 +175,7 @@ static int vpd_is_valid(unsigned dev_addr, unsigned char *buf) calc_crc16 = (0xffff & crc32(0, buf, num_bytes)); #endif /* Now restore the CRC */ - *(ushort *) packet->data = stored_crc16; + memcpy(packet->data, &stored_crc16, sizeof(ushort)); if (stored_crc16 != calc_crc16) { printf("Error: VPD EEPROM 0x%x has bad CRC 0x%x\n", dev_addr, stored_crc16); @@ -277,8 +277,9 @@ int vpd_get_data(unsigned char dev_addr, VPD *vpdInfo) break; case VPD_PID_SN: if (size_ok(packet, sizeof(unsigned long))) { - vpdInfo->serialNum = - *(unsigned long *) packet->data; + memcpy(&vpdInfo->serialNum, + packet->data, + sizeof(unsigned long)); } break; case VPD_PID_MANID: @@ -287,19 +288,22 @@ int vpd_get_data(unsigned char dev_addr, VPD *vpdInfo) break; case VPD_PID_PCO: if (size_ok(packet, sizeof(unsigned long))) { - vpdInfo->configOpt = - *(unsigned long *) packet->data; + memcpy(&vpdInfo->configOpt, + packet->data, + sizeof(unsigned long)); } break; case VPD_PID_SYSCLK: if (size_ok(packet, sizeof(unsigned long))) - vpdInfo->sysClk = - *(unsigned long *) packet->data; + memcpy(&vpdInfo->sysClk, + packet->data, + sizeof(unsigned long)); break; case VPD_PID_SERCLK: if (size_ok(packet, sizeof(unsigned long))) - vpdInfo->serClk = - *(unsigned long *) packet->data; + memcpy(&vpdInfo->serClk, + packet->data, + sizeof(unsigned long)); break; case VPD_PID_FLASH: if (size_ok(packet, 9)) { /* XXX - hardcoded,