From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Qiu Subject: [PATCH 1/2 v2] lib/librte_lpm: Fix anonymous union initialization issue Date: Wed, 30 Mar 2016 11:38:12 +0800 Message-ID: <1459309092-8904-1-git-send-email-michael.qiu@intel.com> References: <1458890426-20688-2-git-send-email-michael.qiu@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: Michael Qiu To: dev@dpdk.org Return-path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 961F1CE7 for ; Wed, 30 Mar 2016 05:38:33 +0200 (CEST) In-Reply-To: <1458890426-20688-2-git-send-email-michael.qiu@intel.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" In SUSE11-SP3 i686 platform, with gcc 4.5.1, there is a compile issue: rte_lpm.c: In function =E2=80=98add_depth_small_v20=E2=80=99: rte_lpm.c:778:7: error: unknown field =E2=80=98next_hop=E2=80=99 specified in initializer cc1: warnings being treated as errors The root casue is gcc only allow anonymous union initialized according to the field it is defined. But next_hop is defined in different field when in different platform(Endian). One solution is add if define in the code to avoid this issue, but there is a simple way, initialize it separately later. Fixes: afc5c914a083 ("lpm: fix big endian support") Signed-off-by: Michael Qiu --- v2 --> v1: Fixes whilespace issue around "=3D" lib/librte_lpm/rte_lpm.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c index af5811c..efd507e 100644 --- a/lib/librte_lpm/rte_lpm.c +++ b/lib/librte_lpm/rte_lpm.c @@ -744,11 +744,11 @@ add_depth_small_v20(struct rte_lpm_v20 *lpm, uint32= _t ip, uint8_t depth, lpm->tbl24[i].depth <=3D depth)) { =20 struct rte_lpm_tbl_entry_v20 new_tbl24_entry =3D { - { .next_hop =3D next_hop, }, .valid =3D VALID, .valid_group =3D 0, .depth =3D depth, }; + new_tbl24_entry.next_hop =3D next_hop; =20 /* Setting tbl24 entry in one go to avoid race * conditions @@ -775,8 +775,8 @@ add_depth_small_v20(struct rte_lpm_v20 *lpm, uint32_t= ip, uint8_t depth, .valid =3D VALID, .valid_group =3D VALID, .depth =3D depth, - .next_hop =3D next_hop, }; + new_tbl8_entry.next_hop =3D next_hop; =20 /* * Setting tbl8 entry in one go to avoid @@ -975,10 +975,9 @@ add_depth_big_v20(struct rte_lpm_v20 *lpm, uint32_t = ip_masked, uint8_t depth, struct rte_lpm_tbl_entry_v20 new_tbl8_entry =3D { .valid =3D VALID, .depth =3D depth, - .next_hop =3D next_hop, .valid_group =3D lpm->tbl8[i].valid_group, }; - + new_tbl8_entry.next_hop =3D next_hop; /* * Setting tbl8 entry in one go to avoid race * condition @@ -1375,9 +1374,9 @@ delete_depth_small_v20(struct rte_lpm_v20 *lpm, uin= t32_t ip_masked, .valid =3D VALID, .valid_group =3D VALID, .depth =3D sub_rule_depth, - .next_hop =3D lpm->rules_tbl - [sub_rule_index].next_hop, }; + new_tbl8_entry.next_hop =3D + lpm->rules_tbl[sub_rule_index].next_hop; =20 for (i =3D tbl24_index; i < (tbl24_index + tbl24_range); i++) { =20 @@ -1639,9 +1638,10 @@ delete_depth_big_v20(struct rte_lpm_v20 *lpm, uint= 32_t ip_masked, .valid =3D VALID, .depth =3D sub_rule_depth, .valid_group =3D lpm->tbl8[tbl8_group_start].valid_group, - .next_hop =3D lpm->rules_tbl[sub_rule_index].next_hop, }; =20 + new_tbl8_entry.next_hop =3D + lpm->rules_tbl[sub_rule_index].next_hop; /* * Loop through the range of entries on tbl8 for which the * rule_to_delete must be modified. --=20 1.9.3