From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qg0-f51.google.com (mail-qg0-f51.google.com [209.85.192.51]) by dpdk.org (Postfix) with ESMTP id EBC9F8048 for ; Wed, 3 Dec 2014 16:57:41 +0100 (CET) Received: by mail-qg0-f51.google.com with SMTP id l89so10909650qgf.24 for ; Wed, 03 Dec 2014 07:57:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=uATrcDMnQl1RmFG51TMTJaHzqc7zUQDhqCQoVdacWZQ=; b=Y6ApkqDEWAzaqnCeihloBMLAcUlF2WEXPBlGNoN/XV/vd3YTcHnWxaTVCnHnLr3LUp gYixrleNtb82fVdnGPS2hpoPK9oI3rNEPiGV+ripB7u+yhGfZX1tCz1PJcE66135Curk fR+J+by61K5Iew/jb771XCxCKXUyloUIm1N6j8EwRXvTrrkzkyB/DHBkiBmhCopgMq6Q GtBVZiGQTvAXKlswHiFkIYYA1fBlK6aWXM6X9HwUVZRgDARTw8EoCsPNtfIf5Ijhf8F+ 9gp1XoiWIE2bY2Aja5uaDSEkro8IrX0iCBSO6APCFXTCmV9UGtLHV4yqUOG/Q+jlXcDk VPhQ== MIME-Version: 1.0 X-Received: by 10.224.29.84 with SMTP id p20mr8963436qac.13.1417622261407; Wed, 03 Dec 2014 07:57:41 -0800 (PST) Received: by 10.140.93.200 with HTTP; Wed, 3 Dec 2014 07:57:41 -0800 (PST) In-Reply-To: <20141203114258.GA2396@bricha3-MOBL3> References: <1417606044-3432-1-git-send-email-michael.qiu@intel.com> <1417606099-3489-1-git-send-email-michael.qiu@intel.com> <20141203114258.GA2396@bricha3-MOBL3> Date: Wed, 3 Dec 2014 23:57:41 +0800 Message-ID: From: Dayu Qiu To: Bruce Richardson Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH] 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: Wed, 03 Dec 2014 15:57:42 -0000 Just re-post this mail as Thomas said it missed in mail list. On Wed, Dec 3, 2014 at 7:42 PM, Bruce Richardson wrote: > On Wed, Dec 03, 2014 at 07:28:19PM +0800, Michael Qiu wrote: > > app/test-pmd/csumonly.c: In function =E2=80=98get_psd_sum=E2=80=99: > > build/include/rte_ip.h:161: error: dereferencing pointer =E2=80=98u16= =E2=80=99 > > does break strict-aliasing rules > > build/include/rte_ip.h:157: note: initialized from here > > ... > > > > The root cause is that, compile enable strict aliasing by default, > > while in function rte_raw_cksum() try to convert 'const char *' > > to 'const uint16_t *'. > > > > What compiler version is this with? Is there any other way to fix this > other than disabling the compiler warnings. Turning off strict aliasing m= ay > affect performance as it reduces the number of optimizations that the > compiler > can perform. > > The compile version is: $ gcc -v Using built-in specs. Target: x86_64-redhat-linux ... gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) The OS is centos6.5 x86_64 Actually, another possible solution is, as gcc manual shows, use union. In function rte_raw_cksum() of lib/librte_net/rte_ip.h: static inline uint16_t rte_raw_cksum(const char *buf, size_t len){ union { const char *ubuf; const uint16_t *uu16; } convert; convert.ubuf =3D buf; const uint16_t *u16 =3D convert.uu16; ... } This may be work, but not test yet. Thanks, Michael > /Bruce > > > Need to add CFLAG '-Wno-strict-aliasing' to avoid this issue. > > > > Signed-off-by: Michael Qiu > > --- > > app/test-pmd/Makefile | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/app/test-pmd/Makefile b/app/test-pmd/Makefile > > index 97dc2e6..995c874 100644 > > --- a/app/test-pmd/Makefile > > +++ b/app/test-pmd/Makefile > > @@ -38,7 +38,7 @@ ifeq ($(CONFIG_RTE_TEST_PMD),y) > > # > > APP =3D testpmd > > > > -CFLAGS +=3D -O3 > > +CFLAGS +=3D -O3 -Wno-strict-aliasing > > CFLAGS +=3D $(WERROR_FLAGS) > > > > ifeq ($(CONFIG_RTE_LIBRTE_PMD_PCAP),y) > > -- > > 1.9.3 > > > --=20 Thanks & Best Regards Mike