From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pd0-f174.google.com (mail-pd0-f174.google.com [209.85.192.174]) by dpdk.org (Postfix) with ESMTP id 606C88032 for ; Thu, 4 Dec 2014 13:46:44 +0100 (CET) Received: by mail-pd0-f174.google.com with SMTP id w10so17543164pde.19 for ; Thu, 04 Dec 2014 04:46:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=VB6Mw3P+o77Ry2PWvqBHTVNm3UecNJlNT3BBVrnv0Qk=; b=d/TahOABM+laPJhMW28Gdlk+Rbscy3Ipbu17pt/0ykRWUl6Bk+qOX7iosf+3yfKnRH r/OHu+oTXVSnY5QmAXObPMnQs7aeax29toP8zDy9tEIfOCoaI7Vo2ClAhQLUbNbzfQVL lJwNHDJqYB09uM/YyGpEuisotCXNuPLcDsKgyLvUdo8p9m+AlMcCjdqVdeEfWYTTa4Rl o/d/kDlMQZ5/FfOmcJeidKsfNfUWTZknCHcONcDnPQ/rdwJuTVNC9/lCqln4+/dHeP9e J7DN0uJFtp47Svgqb0Z1Wg67mgtB9+dMv4qsCmimX2zeqeZXEygYTsbE06UTdMKe06r9 822Q== X-Received: by 10.68.95.228 with SMTP id dn4mr25657722pbb.10.1417697203466; Thu, 04 Dec 2014 04:46:43 -0800 (PST) Received: from localhost.localdomain.localdomain ([180.99.189.223]) by mx.google.com with ESMTPSA id fb7sm26118719pab.10.2014.12.04.04.46.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Dec 2014 04:46:42 -0800 (PST) From: Michael Qiu X-Google-Original-From: Michael Qiu To: dev@dpdk.org Date: Thu, 4 Dec 2014 11:28:31 +0800 Message-Id: <1417663711-19576-1-git-send-email-michael.qiu@intel.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <533710CFB86FA344BFBF2D6802E60286C9C893@SHSMSX101.ccr.corp.intel.com> References: <533710CFB86FA344BFBF2D6802E60286C9C893@SHSMSX101.ccr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2] 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: Thu, 04 Dec 2014 12:46:44 -0000 app/test-pmd/csumonly.c: In function ‘get_psd_sum’: build/include/rte_ip.h:161: error: dereferencing pointer ‘u16’ 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 *'. This patch is one workaround fix. Signed-off-by: Michael Qiu --- lib/librte_net/rte_ip.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/librte_net/rte_ip.h b/lib/librte_net/rte_ip.h index 61e4457..f1c7087 100644 --- a/lib/librte_net/rte_ip.h +++ b/lib/librte_net/rte_ip.h @@ -154,7 +154,8 @@ struct ipv4_hdr { static inline uint16_t rte_raw_cksum(const char *buf, size_t len) { - const uint16_t *u16 = (const uint16_t *)buf; + unsigned long ptr = (unsigned long)buf; + const uint16_t *u16 = (const uint16_t *)ptr; uint32_t sum = 0; while (len >= (sizeof(*u16) * 4)) { -- 1.9.3