fix build with option -O1
cover fix build with option -O1
When trying to compile with -O1, the compiler shows some errors. Some are justified, others look like compiler bug. Anyway, it's better to fix all of them.
Thomas Monjalon (5):
eal: fix build with -O1
kni: fix possible uninitialized variable net/mlx4: fix possible uninitialized variable
eventdev: fix possible uninitialized variable app/eventdev: fix possible uninitialized variable
app/test-eventdev/test_pipeline_common.c | 2 +- drivers/net/mlx4/mlx4_ethdev.c | 2 ++ lib/librte_eal/common/include/rte_common.h | 9 --------- lib/librte_eventdev/rte_event_eth_tx_adapter.c | 2 +- lib/librte_kni/rte_kni.c | 2 +- 5 files changed, 5 insertions(+), 12 deletions(-)
Signature · 1 line
2.19.0
PATCH 1/5 eal: fix build with -O1
In case of optimized compilation, RTE_BUILD_BUG_ON use an external variable which is neither defined, nor used.
It seems not optimized out in case of OPDL compiled with clang -O1:
opdl_ring.c: undefined reference to `RTE_BUILD_BUG_ON_detected_error' clang-6.0: fatal error: linker command failed with exit code 1
--- lib/librte_eal/common/include/rte_common.h | 9 --------- 1 file changed, 9 deletions(-)
lib/librte_eal/common/include/rte_common.h +0 -9
@@ -270,16 +270,7 @@ rte_is_aligned(void *ptr, unsigned align)/** * Triggers an error at compilation time if the condition is true. */ -#ifndef __OPTIMIZE__#define RTE_BUILD_BUG_ON (condition) ((void)sizeof(char[1 - 2*!!(condition)])) -#else -extern int RTE_BUILD_BUG_ON_detected_error; -#define RTE_BUILD_BUG_ON (condition) do { \ - ((void)sizeof(char[1 - 2*!!(condition)])); \ - if (condition) \ - RTE_BUILD_BUG_ON_detected_error = 1; \ -} while(0) -#endif /** * Combines 32b inputs most significant set bits into the least
Signature · 1 line
2.19.0
PATCH 2/5 kni: fix possible uninitialized variable
In reply to Thomas MonjalonThis error can be raised:
lib/librte_kni/rte_kni.c:531:15: error: 'req' may be used uninitialized in this function
It should not happen because kni_fifo_get() would return 0 if req is not initialized, so the function would return before using req. But GCC complains about it in -O1 optimization,
and a NULL initialization is harmless here.
--- lib/librte_kni/rte_kni.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_kni/rte_kni.c +1 -1
@@ -483,7 +483,7 @@ int rte_kni_handle_request(struct rte_kni *kni) {unsigned ret; -struct rte_kni_request *req; +struct rte_kni_request *req =NULL ;if (kni ==NULL )return -1 ;
Signature · 1 line
2.19.0
PATCH 3/5 net/mlx4: fix possible uninitialized variable
In reply to Thomas MonjalonWhen compiling with gcc -O1, this error appears:
drivers/net/mlx4/mlx4_ethdev.c: In function ‘mlx4_rxmode_toggle’:
rte_log.h:321:3: error:
‘mode’ may be used uninitialized in this function
The function mlx4_rxmode_toggle is never called with a value which is not in the switch block, but GCC complains about it with -O1. So the default case is "fixed" by setting string "undefined".
--- drivers/net/mlx4/mlx4_ethdev.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/mlx4/mlx4_ethdev.c +2 -0
@@ -360,6 +360,8 @@ mlx4_rxmode_toggle(struct rte_eth_dev *dev, enum rxmode_toggle toggle) mode ="all multicast" ; dev->data->all_multicast = toggle &1 ;break ; +default : + mode ="undefined" ; }if (!mlx4_flow_sync (priv, &error))return ;
Signature · 1 line
2.19.0
PATCH 4/5 eventdev: fix possible uninitialized variable
In reply to Thomas MonjalonWhen compiling with -O1, this error can appear:
lib/librte_eventdev/rte_event_eth_tx_adapter.c:705:6: error: ‘ret’ may be used uninitialized in this function
If tx_queue_id is -1 and nb_queues is 0, then ret is returned without being initialized.
It is fixed by setting 0 as initial value.
--- lib/librte_eventdev/rte_event_eth_tx_adapter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/librte_eventdev/rte_event_eth_tx_adapter.c +1 -1
@@ -702,7 +702,7 @@ txa_service_queue_add(uint8_t id,struct txa_service_queue_info *tqi;struct rte_eth_dev_tx_buffer *tb;struct txa_retry *txa_retry; -int ret; +int ret =0 ; txa =txa_service_id_to_data (id);
Signature · 1 line
2.19.0
PATCH 5/5 app/eventdev: fix possible uninitialized variable
In reply to Thomas MonjalonWhen compiling with -O1, this error can appear:
app/test-eventdev/test_pipeline_common.c:332:6: error: ‘ret’ may be used uninitialized in this function
If there is no device, then ret is returned without being initialized. It is fixed by setting 0 as initial value.
--- app/test-eventdev/test_pipeline_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
app/test-eventdev/test_pipeline_common.c +1 -1
@@ -329,7 +329,7 @@ int pipeline_event_tx_adapter_setup(struct evt_options *opt, struct rte_event_port_conf port_conf) { - int ret; + int ret = 0;uint16_t consm;RTE_ETH_FOREACH_DEV (consm) {
Signature · 1 line
2.19.0
Thomas Monjalon
AppliedQuoted 6 lines
Thomas Monjalon (5):
eal: fix build with -O1
kni: fix possible uninitialized variable net/mlx4: fix possible uninitialized variable
eventdev: fix possible uninitialized variable app/eventdev: fix possible uninitialized variable
Applied