[dpdk-dev,2/5] lpm: fix compilation on ARM BE

Message ID 1509617335-6354-2-git-send-email-hemant.agrawal@nxp.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Hemant Agrawal Nov. 2, 2017, 10:08 a.m. UTC
  Compiling on ARM BE using Linaro toolchain caused following
error/warnings.

rte_lpm.c: In function ‘add_depth_big_v20’:
rte_lpm.c:911:4: error: braces around scalar initializer [-Werror]
    { .group_idx = (uint8_t)tbl8_group_index, },
    ^
rte_lpm.c:911:4: note: (near initialization for
	‘new_tbl24_entry.depth’)
rte_lpm.c:911:6:error: field name not in record or union initializer
    { .group_idx = (uint8_t)tbl8_group_index, },
      ^
rte_lpm.c:911:6: note: (near initialization for
	‘new_tbl24_entry.depth’)
rte_lpm.c:914:13: error: initialized field overwritten
	[-Werror=override-init]
    .depth = 0,

Fixes: dc81ebbacaeb ("lpm: extend IPv4 next hop field")
Cc: Michal Kobylinski <michalx.kobylinski@intel.com>
Cc: stable@dpdk.org

Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 lib/librte_lpm/rte_lpm.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
  

Comments

Bruce Richardson Dec. 11, 2017, 12:41 p.m. UTC | #1
On Thu, Nov 02, 2017 at 03:38:52PM +0530, Hemant Agrawal wrote:
> Compiling on ARM BE using Linaro toolchain caused following
> error/warnings.
> 
> rte_lpm.c: In function ‘add_depth_big_v20’:
> rte_lpm.c:911:4: error: braces around scalar initializer [-Werror]
>     { .group_idx = (uint8_t)tbl8_group_index, },
>     ^
> rte_lpm.c:911:4: note: (near initialization for
> 	‘new_tbl24_entry.depth’)
> rte_lpm.c:911:6:error: field name not in record or union initializer
>     { .group_idx = (uint8_t)tbl8_group_index, },
>       ^
> rte_lpm.c:911:6: note: (near initialization for
> 	‘new_tbl24_entry.depth’)
> rte_lpm.c:914:13: error: initialized field overwritten
> 	[-Werror=override-init]
>     .depth = 0,
> 
> Fixes: dc81ebbacaeb ("lpm: extend IPv4 next hop field")
> Cc: Michal Kobylinski <michalx.kobylinski@intel.com>
> Cc: stable@dpdk.org
> 
> Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
> ---

Acked-by: Bruce Richardson <bruce.richardson@intel.com>
  
Hemant Agrawal Dec. 13, 2017, 12:23 p.m. UTC | #2
On 12/11/2017 6:11 PM, Bruce Richardson wrote:
> On Thu, Nov 02, 2017 at 03:38:52PM +0530, Hemant Agrawal wrote:
>> Compiling on ARM BE using Linaro toolchain caused following
>> error/warnings.
>>
>> rte_lpm.c: In function ‘add_depth_big_v20’:
>> rte_lpm.c:911:4: error: braces around scalar initializer [-Werror]
>>     { .group_idx = (uint8_t)tbl8_group_index, },
>>     ^
>> rte_lpm.c:911:4: note: (near initialization for
>> 	‘new_tbl24_entry.depth’)
>> rte_lpm.c:911:6:error: field name not in record or union initializer
>>     { .group_idx = (uint8_t)tbl8_group_index, },
>>       ^
>> rte_lpm.c:911:6: note: (near initialization for
>> 	‘new_tbl24_entry.depth’)
>> rte_lpm.c:914:13: error: initialized field overwritten
>> 	[-Werror=override-init]
>>     .depth = 0,
>>
>> Fixes: dc81ebbacaeb ("lpm: extend IPv4 next hop field")
>> Cc: Michal Kobylinski <michalx.kobylinski@intel.com>
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
>> ---
>
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
>
Thanks for review. I found a better solution, I will be sending a v2.
  

Patch

diff --git a/lib/librte_lpm/rte_lpm.c b/lib/librte_lpm/rte_lpm.c
index 140dbb2..3723743 100644
--- a/lib/librte_lpm/rte_lpm.c
+++ b/lib/librte_lpm/rte_lpm.c
@@ -913,7 +913,7 @@  add_depth_big_v20(struct rte_lpm_v20 *lpm, uint32_t ip_masked, uint8_t depth,
 		 */
 
 		struct rte_lpm_tbl_entry_v20 new_tbl24_entry = {
-			{ .group_idx = (uint8_t)tbl8_group_index, },
+			.group_idx = (uint8_t)tbl8_group_index,
 			.valid = VALID,
 			.valid_group = 1,
 			.depth = 0,
@@ -959,7 +959,7 @@  add_depth_big_v20(struct rte_lpm_v20 *lpm, uint32_t ip_masked, uint8_t depth,
 		 */
 
 		struct rte_lpm_tbl_entry_v20 new_tbl24_entry = {
-				{ .group_idx = (uint8_t)tbl8_group_index, },
+				.group_idx = (uint8_t)tbl8_group_index,
 				.valid = VALID,
 				.valid_group = 1,
 				.depth = 0,
@@ -1366,7 +1366,7 @@  delete_depth_small_v20(struct rte_lpm_v20 *lpm, uint32_t ip_masked,
 		 */
 
 		struct rte_lpm_tbl_entry_v20 new_tbl24_entry = {
-			{.next_hop = lpm->rules_tbl[sub_rule_index].next_hop,},
+			.next_hop = lpm->rules_tbl[sub_rule_index].next_hop,
 			.valid = VALID,
 			.valid_group = 0,
 			.depth = sub_rule_depth,
@@ -1669,7 +1669,7 @@  delete_depth_big_v20(struct rte_lpm_v20 *lpm, uint32_t ip_masked,
 	} else if (tbl8_recycle_index > -1) {
 		/* Update tbl24 entry. */
 		struct rte_lpm_tbl_entry_v20 new_tbl24_entry = {
-			{ .next_hop = lpm->tbl8[tbl8_recycle_index].next_hop, },
+			.next_hop = lpm->tbl8[tbl8_recycle_index].next_hop,
 			.valid = VALID,
 			.valid_group = 0,
 			.depth = lpm->tbl8[tbl8_recycle_index].depth,