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 AA003569C for ; Wed, 9 Dec 2015 09:44:33 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP; 09 Dec 2015 00:44:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,402,1444719600"; d="scan'208";a="869833586" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by fmsmga002.fm.intel.com with ESMTP; 09 Dec 2015 00:44:32 -0800 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id tB98iTEB004387; Wed, 9 Dec 2015 16:44:29 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id tB98iRd7026101; Wed, 9 Dec 2015 16:44:29 +0800 Received: (from dayuqiu@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id tB98iRZu026097; Wed, 9 Dec 2015 16:44:27 +0800 From: Michael Qiu To: dev@dpdk.org Date: Wed, 9 Dec 2015 16:44:26 +0800 Message-Id: <1449650666-26067-1-git-send-email-michael.qiu@intel.com> X-Mailer: git-send-email 1.7.4.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] examples/ip_pipeline: Fix compile issue with strict-aliasing 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, 09 Dec 2015 08:44:34 -0000 Compile ip_pipeline in CentOS 6.5 with kernel 2.6.32-431 GCC 4.4.7, will lead below error: pipeline_routing_be.c: In function ‘pipeline_routing_msg_req_arp_add_handler’: pipeline_routing_be.c:1817: error: dereferencing pointer ‘({anonymous})’ does break strict-aliasing rules This because the code break strict-aliasing rule. The patch solve this issue. Fixes: 0ae7275810f1 (examples/ip_pipeline: add more functions to routing pipeline) Signed-off-by: Michael Qiu --- examples/ip_pipeline/pipeline/pipeline_routing_be.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/examples/ip_pipeline/pipeline/pipeline_routing_be.c b/examples/ip_pipeline/pipeline/pipeline_routing_be.c index 4a95c7d..9baabd0 100644 --- a/examples/ip_pipeline/pipeline/pipeline_routing_be.c +++ b/examples/ip_pipeline/pipeline/pipeline_routing_be.c @@ -1461,8 +1461,7 @@ pipeline_routing_msg_req_route_add_handler(struct pipeline *p, void *msg) uint64_t macaddr_dst; uint64_t ethertype = ETHER_TYPE_IPv4; - *((struct ether_addr *) &macaddr_dst) = - req->data.ethernet.macaddr; + macaddr_dst = *((uint64_t *)&(req->data.ethernet.macaddr)); macaddr_dst = rte_bswap64(macaddr_dst << 16); entry_arp0.slab[0] = @@ -1503,8 +1502,7 @@ pipeline_routing_msg_req_route_add_handler(struct pipeline *p, void *msg) uint64_t svlan = req->data.l2.qinq.svlan; uint64_t cvlan = req->data.l2.qinq.cvlan; - *((struct ether_addr *) &macaddr_dst) = - req->data.ethernet.macaddr; + macaddr_dst = *((uint64_t *)&(req->data.ethernet.macaddr)); macaddr_dst = rte_bswap64(macaddr_dst << 16); entry_arp0.slab[0] = rte_bswap64((svlan << 48) | @@ -1563,8 +1561,7 @@ pipeline_routing_msg_req_route_add_handler(struct pipeline *p, void *msg) uint64_t label3 = req->data.l2.mpls.labels[3]; uint32_t n_labels = req->data.l2.mpls.n_labels; - *((struct ether_addr *) &macaddr_dst) = - req->data.ethernet.macaddr; + macaddr_dst = *((uint64_t *)&(req->data.ethernet.macaddr)); macaddr_dst = rte_bswap64(macaddr_dst << 16); switch (n_labels) { @@ -1814,7 +1811,7 @@ pipeline_routing_msg_req_arp_add_handler(struct pipeline *p, void *msg) return rsp; } - *((struct ether_addr *) &entry.macaddr) = req->macaddr; + entry.macaddr = *((uint64_t *)&(req->macaddr)); entry.macaddr = entry.macaddr << 16; rsp->status = rte_pipeline_table_entry_add(p->p, -- 1.9.3