[v5,03/11] eventdev: fix possible use of uninitialized var

Message ID 20191028142145.3758-4-aostruszka@marvell.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series Add an option to use LTO for DPDK build |

Checks

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

Commit Message

Andrzej Ostruszka [C] Oct. 28, 2019, 2:21 p.m. UTC
  Fix the logic for the case of event queue allowing all schedule types.

Compiler warning pointing to this error (with LTO enabled):
error: ‘sched_type’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]
  if ((ret < 0 && ret != -EOVERFLOW) ||

Fixes: 6750b21bd6af ("eventdev: add default software timer adapter")
Signed-off-by: Andrzej Ostruszka <aostruszka@marvell.com>
---
 lib/librte_eventdev/rte_event_timer_adapter.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
  

Patch

diff --git a/lib/librte_eventdev/rte_event_timer_adapter.c b/lib/librte_eventdev/rte_event_timer_adapter.c
index 5ce399eca..161e21a68 100644
--- a/lib/librte_eventdev/rte_event_timer_adapter.c
+++ b/lib/librte_eventdev/rte_event_timer_adapter.c
@@ -706,11 +706,11 @@  check_destination_event_queue(struct rte_event_timer *evtim,
 				       RTE_EVENT_QUEUE_ATTR_SCHEDULE_TYPE,
 				       &sched_type);
 
-	if ((ret < 0 && ret != -EOVERFLOW) ||
-	    evtim->ev.sched_type != sched_type)
-		return -1;
+	if ((ret == 0 && evtim->ev.sched_type == sched_type) ||
+	    ret == -EOVERFLOW)
+		return 0;
 
-	return 0;
+	return -1;
 }
 
 static int