From 70a74530f29f10b7891a5311098b1c3905350785 Mon Sep 17 00:00:00 2001 From: markhermelinggt Date: Tue, 5 Nov 2019 10:36:23 -0500 Subject: [PATCH] xQueuePeek with third parameter '0' does not initialize the 2nd parameter If the queue is empty, then priority in commanderSetSetpoint is not initialized. The same holds for commanderGetSetpoint (the XQueuePeek would not initialize set point on line 81 if the queue is empty, but it is not clear to me how to fix that code. @ataffanel : This is a similar problem as I reported earlier. Unclear to me if this queue can ever be empty. --- src/modules/src/commander.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/src/commander.c b/src/modules/src/commander.c index cc0e29b861..b1c8f1d6fb 100644 --- a/src/modules/src/commander.c +++ b/src/modules/src/commander.c @@ -66,9 +66,9 @@ void commanderInit(void) void commanderSetSetpoint(setpoint_t *setpoint, int priority) { int currentPriority; - xQueuePeek(priorityQueue, ¤tPriority, 0); - if (priority >= currentPriority) { + + if (xQueuePeek(priorityQueue, ¤tPriority, 0) == pdPass && priority >= currentPriority) { setpoint->timestamp = xTaskGetTickCount(); // This is a potential race but without effect on functionality xQueueOverwrite(setpointQueue, setpoint);