From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id C463D7E1B for ; Fri, 5 Dec 2014 06:35:48 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 04 Dec 2014 21:35:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,520,1413270000"; d="scan'208";a="619000838" Received: from kmsmsx153.gar.corp.intel.com ([172.21.73.88]) by orsmga001.jf.intel.com with ESMTP; 04 Dec 2014 21:35:46 -0800 Received: from pgsmsx101.gar.corp.intel.com (10.221.44.78) by KMSMSX153.gar.corp.intel.com (172.21.73.88) with Microsoft SMTP Server (TLS) id 14.3.195.1; Fri, 5 Dec 2014 13:34:38 +0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by PGSMSX101.gar.corp.intel.com (10.221.44.78) with Microsoft SMTP Server (TLS) id 14.3.195.1; Fri, 5 Dec 2014 13:34:38 +0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.110]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.240]) with mapi id 14.03.0195.001; Fri, 5 Dec 2014 13:34:36 +0800 From: "Qiu, Michael" To: Michael Qiu , "dev@dpdk.org" Thread-Topic: [PATCH v3] test-pmd: Fix pointer aliasing error Thread-Index: AQHQD8cg6//kKikCHUuP3ggaMBczHg== Date: Fri, 5 Dec 2014 05:34:35 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E60286C9CFE5@SHSMSX101.ccr.corp.intel.com> References: <1417663711-19576-1-git-send-email-michael.qiu@intel.com> <1417666564-19950-1-git-send-email-michael.qiu@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH v3] test-pmd: Fix pointer aliasing error X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Dec 2014 05:35:49 -0000 Any comments about this version? a new workaround solution :)=0A= =0A= Thanks,=0A= Michael=0A= On 12/4/2014 9:35 PM, Michael Qiu wrote:=0A= > app/test-pmd/csumonly.c: In function =91get_psd_sum=92:=0A= > build/include/rte_ip.h:161: error: dereferencing pointer =91u16=92=0A= > does break strict-aliasing rules=0A= > build/include/rte_ip.h:157: note: initialized from here=0A= > ...=0A= >=0A= > The root cause is that, compile enable strict aliasing by default,=0A= > while in function rte_raw_cksum() try to convert 'const char *'=0A= > to 'const uint16_t *'.=0A= >=0A= > This patch is one workaround fix.=0A= >=0A= > Signed-off-by: Michael Qiu =0A= > ---=0A= > v3 --> v2:=0A= > use uintptr_t instead of unsigned long to=0A= > save pointer.=0A= >=0A= > v2 --> v1:=0A= > Workaround solution instead of shut off the=0A= > gcc params.=0A= >=0A= > lib/librte_net/rte_ip.h | 3 ++-=0A= > 1 file changed, 2 insertions(+), 1 deletion(-)=0A= >=0A= > diff --git a/lib/librte_net/rte_ip.h b/lib/librte_net/rte_ip.h=0A= > index 61e4457..cda3436 100644=0A= > --- a/lib/librte_net/rte_ip.h=0A= > +++ b/lib/librte_net/rte_ip.h=0A= > @@ -154,7 +154,8 @@ struct ipv4_hdr {=0A= > static inline uint16_t=0A= > rte_raw_cksum(const char *buf, size_t len)=0A= > {=0A= > - const uint16_t *u16 =3D (const uint16_t *)buf;=0A= > + uintptr_t ptr =3D (uintptr_t)buf;=0A= > + const uint16_t *u16 =3D (const uint16_t *)ptr;=0A= > uint32_t sum =3D 0;=0A= > =0A= > while (len >=3D (sizeof(*u16) * 4)) {=0A= =0A=