Skip to contentSkip to conversation

service: fix build error "ids uninitialized in rte_service_map_lcore_set"

PATCH Applied Yi Yang 3 participants 3 messages Sep 21, 2017

lore
Share & tools
lore

Yi Yang

author
#0 lore raw

PATCH v2 1/1 service: fix build error "ids uninitialized in rte_service_map_lcore_set"

v1->v2
- Change title to more descriptive one
- Add issue reproduce information to git log body

On current master tree, normal DPDK make will result in the below error:

error: ‘ids[0]’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
ret = rte_service_map_lcore_set(i, ids[lcore_iter], 1);

It can be reproduced very easily on Fedora 21 with gcc-4.9.2-6.fc21.x86_64.

It is fixed after applied this patch.

---
 lib/librte_eal/common/rte_service.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_eal/common/rte_service.c +1 -1
index 43716bb..e598e16 100644
@@ -431,7 +431,7 @@ rte_service_start_with_defaults(void)
 	uint32_t count = rte_service_get_count();
 
 	int32_t lcore_iter = 0;
-	uint32_t ids[RTE_MAX_LCORE];
+	uint32_t ids[RTE_MAX_LCORE] = {0};
 	int32_t lcore_count = rte_service_lcore_list(ids, RTE_MAX_LCORE);
 
 	if (lcore_count == 0)
Signature · 1 line
2.1.0
Acked-by on v2 1/1
#1 lore raw
Quoted 19 lines

From: Yang, Yi Y
Sent: Thursday, September 21, 2017 2:51 AM
To: [email protected]
Cc: Van Haaren, Harry <[email protected]>; Yang, Yi Y <[email protected]>
Subject: [PATCH v2] service: fix build error "ids uninitialized in rte_service_map_lcore_set"

v1->v2
- Change title to more descriptive one
- Add issue reproduce information to git log body

On current master tree, normal DPDK make will result in the below error:

error: ‘ids[0]’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
ret = rte_service_map_lcore_set(i, ids[lcore_iter], 1);

Quoted 6 lines

It can be reproduced very easily on Fedora 21 with gcc-4.9.2-6.fc21.x86_64.

It is fixed after applied this patch.

+CC Thomas, please pull this asap, as it causes build issues on various GCC/OS versions.

Quoted 20 lines
---
 lib/librte_eal/common/rte_service.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_eal/common/rte_service.c +1 -2
index 43716bb..e598e16 100644
@@ -431,7 +431,7 @@ rte_service_start_with_defaults(void)
 	uint32_t count = rte_service_get_count();
 
 	int32_t lcore_iter = 0;
-	uint32_t ids[RTE_MAX_LCORE];
+	uint32_t ids[RTE_MAX_LCORE] = {0};
 	int32_t lcore_count = rte_service_lcore_list(ids, RTE_MAX_LCORE);
 
 	if (lcore_count == 0)
--

2.1.0

#2 lore raw

21/09/2017 13:55, Van Haaren, Harry:

Quoted 15 lines
Quoted 15 lines

From: Yang, Yi Y
Sent: Thursday, September 21, 2017 2:51 AM
To: [email protected]
Cc: Van Haaren, Harry <[email protected]>; Yang, Yi Y <[email protected]>
Subject: [PATCH v2] service: fix build error "ids uninitialized in rte_service_map_lcore_set"

v1->v2
- Change title to more descriptive one
- Add issue reproduce information to git log body

On current master tree, normal DPDK make will result in the below error:

Quoted 6 lines
Quoted 6 lines

error: ‘ids[0]’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
ret = rte_service_map_lcore_set(i, ids[lcore_iter], 1);

It can be reproduced very easily on Fedora 21 with gcc-4.9.2-6.fc21.x86_64.

Fixes 21698354c832 ("service: introduce service cores concept")
Quoted 5 lines
Quoted 3 lines

It is fixed after applied this patch.

+CC Thomas, please pull this asap, as it causes build issues on various GCC/OS versions.

Most of compilers do not raise an error.
It seems specific to gcc 4.9.
Nelio reported the same error with gcc 4.9. Changing the title to "service: fix build with gcc 4.9"

Quoted 1 line

Applied, thanks