From 14f4dfe79f97c1c90770d2c5c32906799f2a930c Mon Sep 17 00:00:00 2001 From: RichardBarry Date: Tue, 8 Jun 2021 14:19:55 -0700 Subject: [PATCH 1/2] Indent contents of a taskENTER_CRITICAL/taskEXIT_CRITICAL block. Move a few configASSERT() statements out of a path where they would always be triggered to prevent "condition is always true" compiler warnings. --- queue.c | 57 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/queue.c b/queue.c index f5d8fd72ac..f9d64da80e 100644 --- a/queue.c +++ b/queue.c @@ -275,26 +275,31 @@ BaseType_t xQueueGenericReset( QueueHandle_t xQueue, ( ( SIZE_MAX / pxQueue->uxLength ) >= pxQueue->uxItemSize ) ) { taskENTER_CRITICAL(); - - pxQueue->u.xQueue.pcTail = pxQueue->pcHead + ( pxQueue->uxLength * pxQueue->uxItemSize ); /*lint !e9016 Pointer arithmetic allowed on char types, especially when it assists conveying intent. */ - pxQueue->uxMessagesWaiting = ( UBaseType_t ) 0U; - pxQueue->pcWriteTo = pxQueue->pcHead; - pxQueue->u.xQueue.pcReadFrom = pxQueue->pcHead + ( ( pxQueue->uxLength - 1U ) * pxQueue->uxItemSize ); /*lint !e9016 Pointer arithmetic allowed on char types, especially when it assists conveying intent. */ - pxQueue->cRxLock = queueUNLOCKED; - pxQueue->cTxLock = queueUNLOCKED; - - if( xNewQueue == pdFALSE ) { - /* If there are tasks blocked waiting to read from the queue, then - * the tasks will remain blocked as after this function exits the queue - * will still be empty. If there are tasks blocked waiting to write to - * the queue, then one should be unblocked as after this function exits - * it will be possible to write to it. */ - if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) + pxQueue->u.xQueue.pcTail = pxQueue->pcHead + ( pxQueue->uxLength * pxQueue->uxItemSize ); /*lint !e9016 Pointer arithmetic allowed on char types, especially when it assists conveying intent. */ + pxQueue->uxMessagesWaiting = ( UBaseType_t ) 0U; + pxQueue->pcWriteTo = pxQueue->pcHead; + pxQueue->u.xQueue.pcReadFrom = pxQueue->pcHead + ( ( pxQueue->uxLength - 1U ) * pxQueue->uxItemSize ); /*lint !e9016 Pointer arithmetic allowed on char types, especially when it assists conveying intent. */ + pxQueue->cRxLock = queueUNLOCKED; + pxQueue->cTxLock = queueUNLOCKED; + + if( xNewQueue == pdFALSE ) { - if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE ) + /* If there are tasks blocked waiting to read from the queue, then + * the tasks will remain blocked as after this function exits the queue + * will still be empty. If there are tasks blocked waiting to write to + * the queue, then one should be unblocked as after this function exits + * it will be possible to write to it. */ + if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToSend ) ) == pdFALSE ) { - queueYIELD_IF_USING_PREEMPTION(); + if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) != pdFALSE ) + { + queueYIELD_IF_USING_PREEMPTION(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } } else { @@ -303,15 +308,11 @@ BaseType_t xQueueGenericReset( QueueHandle_t xQueue, } else { - mtCOVERAGE_TEST_MARKER(); + /* Ensure the event queues start in the correct state. */ + vListInitialise( &( pxQueue->xTasksWaitingToSend ) ); + vListInitialise( &( pxQueue->xTasksWaitingToReceive ) ); } } - else - { - /* Ensure the event queues start in the correct state. */ - vListInitialise( &( pxQueue->xTasksWaitingToSend ) ); - vListInitialise( &( pxQueue->xTasksWaitingToReceive ) ); - } taskEXIT_CRITICAL(); } else @@ -380,10 +381,10 @@ BaseType_t xQueueGenericReset( QueueHandle_t xQueue, } else { - configASSERT( pxNewQueue ); mtCOVERAGE_TEST_MARKER(); } + configASSERT( pxNewQueue ); return pxNewQueue; } @@ -448,10 +449,10 @@ BaseType_t xQueueGenericReset( QueueHandle_t xQueue, } else { - configASSERT( pxNewQueue ); mtCOVERAGE_TEST_MARKER(); } + configASSERT( pxNewQueue ); return pxNewQueue; } @@ -754,10 +755,10 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, } else { - configASSERT( xHandle ); mtCOVERAGE_TEST_MARKER(); } + configASSERT( xHandle ); return xHandle; } @@ -789,10 +790,10 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, } else { - configASSERT( xHandle ); mtCOVERAGE_TEST_MARKER(); } + configASSERT( xHandle ); return xHandle; } From ea52cee9f9c53736092f2445a646308b2997a09e Mon Sep 17 00:00:00 2001 From: RichardBarry Date: Tue, 8 Jun 2021 15:27:51 -0700 Subject: [PATCH 2/2] Replace configASSERT() positions due to unintended semantic change from the version where asserts were at the top of the file. --- queue.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/queue.c b/queue.c index f9d64da80e..e95a718f60 100644 --- a/queue.c +++ b/queue.c @@ -381,10 +381,10 @@ BaseType_t xQueueGenericReset( QueueHandle_t xQueue, } else { + configASSERT( pxNewQueue ); mtCOVERAGE_TEST_MARKER(); } - configASSERT( pxNewQueue ); return pxNewQueue; } @@ -449,10 +449,10 @@ BaseType_t xQueueGenericReset( QueueHandle_t xQueue, } else { + configASSERT( pxNewQueue ); mtCOVERAGE_TEST_MARKER(); } - configASSERT( pxNewQueue ); return pxNewQueue; } @@ -755,10 +755,10 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, } else { + configASSERT( xHandle ); mtCOVERAGE_TEST_MARKER(); } - configASSERT( xHandle ); return xHandle; } @@ -790,10 +790,10 @@ static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, } else { + configASSERT( xHandle ); mtCOVERAGE_TEST_MARKER(); } - configASSERT( xHandle ); return xHandle; }