Change the input parameter check with assertion.

This commit is contained in:
Ming Yue 2021-03-25 13:34:28 -07:00
parent 64fd9c4435
commit 0df2929dce

View file

@ -625,49 +625,45 @@ EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup,
void vEventGroupDelete( EventGroupHandle_t xEventGroup ) void vEventGroupDelete( EventGroupHandle_t xEventGroup )
{ {
EventGroup_t * pxEventBits; configASSERT( xEventGroup );
const List_t * pxTasksWaitingForBits;
if ( NULL != xEventGroup ) EventGroup_t * pxEventBits = xEventGroup;
const List_t * pxTasksWaitingForBits = &( pxEventBits->xTasksWaitingForBits );
vTaskSuspendAll();
{ {
pxEventBits = xEventGroup; traceEVENT_GROUP_DELETE( xEventGroup );
pxTasksWaitingForBits = &( pxEventBits->xTasksWaitingForBits );
vTaskSuspendAll(); while( listCURRENT_LIST_LENGTH( pxTasksWaitingForBits ) > ( UBaseType_t ) 0 )
{ {
traceEVENT_GROUP_DELETE( xEventGroup ); /* Unblock the task, returning 0 as the event list is being deleted
* and cannot therefore have any bits set. */
configASSERT( pxTasksWaitingForBits->xListEnd.pxNext != ( const ListItem_t * ) &( pxTasksWaitingForBits->xListEnd ) );
vTaskRemoveFromUnorderedEventList( pxTasksWaitingForBits->xListEnd.pxNext, eventUNBLOCKED_DUE_TO_BIT_SET );
}
while( listCURRENT_LIST_LENGTH( pxTasksWaitingForBits ) > ( UBaseType_t ) 0 ) #if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 0 ) )
{ {
/* Unblock the task, returning 0 as the event list is being deleted /* The event group can only have been allocated dynamically - free
* and cannot therefore have any bits set. */ * it again. */
configASSERT( pxTasksWaitingForBits->xListEnd.pxNext != ( const ListItem_t * ) &( pxTasksWaitingForBits->xListEnd ) ); vPortFree( pxEventBits );
vTaskRemoveFromUnorderedEventList( pxTasksWaitingForBits->xListEnd.pxNext, eventUNBLOCKED_DUE_TO_BIT_SET );
} }
#elif ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
#if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 0 ) ) {
/* The event group could have been allocated statically or
* dynamically, so check before attempting to free the memory. */
if( pxEventBits->ucStaticallyAllocated == ( uint8_t ) pdFALSE )
{ {
/* The event group can only have been allocated dynamically - free
* it again. */
vPortFree( pxEventBits ); vPortFree( pxEventBits );
} }
#elif ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) ) else
{ {
/* The event group could have been allocated statically or mtCOVERAGE_TEST_MARKER();
* dynamically, so check before attempting to free the memory. */
if( pxEventBits->ucStaticallyAllocated == ( uint8_t ) pdFALSE )
{
vPortFree( pxEventBits );
}
else
{
mtCOVERAGE_TEST_MARKER();
}
} }
#endif /* configSUPPORT_DYNAMIC_ALLOCATION */ }
} #endif /* configSUPPORT_DYNAMIC_ALLOCATION */
( void ) xTaskResumeAll();
} }
( void ) xTaskResumeAll();
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/