From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pd0-f173.google.com (mail-pd0-f173.google.com [209.85.192.173]) by dpdk.org (Postfix) with ESMTP id 8105E7EB0 for ; Thu, 4 Dec 2014 14:34:28 +0100 (CET) Received: by mail-pd0-f173.google.com with SMTP id ft15so17635012pdb.18 for ; Thu, 04 Dec 2014 05:34:27 -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=ry0p/exYhRaywZRk5DS6ZwKEoe2Ew+BfFR1XND30CZA=; b=ehUcyg5gvPUWlvBE3hCBUtg2zOoCl7H7842Xet5tNBXZHKkfuNllkMbGB4B/mUndFp nY39X+tttTtkJ8BnQkl4e8wp8dF2rHxnPLX2PwzrEwtRVsG+HHHUMasMX5czkgoMQOuZ 4d5dr/2oaelId6+ghcbe8OTIsEdP/3wd0mn/4TULgxamhhajieghwguGlgIR9EGtmivC gwviHIvoY4E4ZUdjqRuJHGyYObUIJGOGeu22gTR7HjbT1oRJ+f7Kc6Va9EUdm0y9HrQh JT/MujGNFenIonNf1ZoQ9qFMWGENI0Jcy8/HKHUcFDtnkqu3/i70SI9ISjV3aFpdry8b WYYg== X-Received: by 10.66.142.137 with SMTP id rw9mr18786417pab.124.1417700067788; Thu, 04 Dec 2014 05:34:27 -0800 (PST) Received: from localhost.localdomain.localdomain ([180.99.189.223]) by mx.google.com with ESMTPSA id ds16sm7391608pdb.65.2014.12.04.05.34.24 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Dec 2014 05:34:27 -0800 (PST) From: Michael Qiu X-Google-Original-From: Michael Qiu To: dev@dpdk.org Date: Thu, 4 Dec 2014 12:16:04 +0800 Message-Id: <1417666564-19950-1-git-send-email-michael.qiu@intel.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1417663711-19576-1-git-send-email-michael.qiu@intel.com> References: <1417663711-19576-1-git-send-email-michael.qiu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [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: Thu, 04 Dec 2014 13:34:29 -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 --- v3 --> v2: use uintptr_t instead of unsigned long to save pointer. v2 --> v1: Workaround solution instead of shut off the gcc params. 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..cda3436 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; + uintptr_t ptr = (uintptr_t)buf; + const uint16_t *u16 = (const uint16_t *)ptr; uint32_t sum = 0; while (len >= (sizeof(*u16) * 4)) { -- 1.9.3