Skip to content

Commit 0df2929

Browse files
committed
Change the input parameter check with assertion.
1 parent 64fd9c4 commit 0df2929

File tree

1 file changed

+26
-30
lines changed

1 file changed

+26
-30
lines changed

event_groups.c

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -625,49 +625,45 @@ EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup,
625625

626626
void vEventGroupDelete( EventGroupHandle_t xEventGroup )
627627
{
628-
EventGroup_t * pxEventBits;
629-
const List_t * pxTasksWaitingForBits;
628+
configASSERT( xEventGroup );
629+
630+
EventGroup_t * pxEventBits = xEventGroup;
631+
const List_t * pxTasksWaitingForBits = &( pxEventBits->xTasksWaitingForBits );
630632

631-
if ( NULL != xEventGroup )
633+
vTaskSuspendAll();
632634
{
633-
pxEventBits = xEventGroup;
634-
pxTasksWaitingForBits = &( pxEventBits->xTasksWaitingForBits );
635+
traceEVENT_GROUP_DELETE( xEventGroup );
635636

636-
vTaskSuspendAll();
637+
while( listCURRENT_LIST_LENGTH( pxTasksWaitingForBits ) > ( UBaseType_t ) 0 )
637638
{
638-
traceEVENT_GROUP_DELETE( xEventGroup );
639+
/* Unblock the task, returning 0 as the event list is being deleted
640+
* and cannot therefore have any bits set. */
641+
configASSERT( pxTasksWaitingForBits->xListEnd.pxNext != ( const ListItem_t * ) &( pxTasksWaitingForBits->xListEnd ) );
642+
vTaskRemoveFromUnorderedEventList( pxTasksWaitingForBits->xListEnd.pxNext, eventUNBLOCKED_DUE_TO_BIT_SET );
643+
}
639644

640-
while( listCURRENT_LIST_LENGTH( pxTasksWaitingForBits ) > ( UBaseType_t ) 0 )
645+
#if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 0 ) )
641646
{
642-
/* Unblock the task, returning 0 as the event list is being deleted
643-
* and cannot therefore have any bits set. */
644-
configASSERT( pxTasksWaitingForBits->xListEnd.pxNext != ( const ListItem_t * ) &( pxTasksWaitingForBits->xListEnd ) );
645-
vTaskRemoveFromUnorderedEventList( pxTasksWaitingForBits->xListEnd.pxNext, eventUNBLOCKED_DUE_TO_BIT_SET );
647+
/* The event group can only have been allocated dynamically - free
648+
* it again. */
649+
vPortFree( pxEventBits );
646650
}
647-
648-
#if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 0 ) )
651+
#elif ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
652+
{
653+
/* The event group could have been allocated statically or
654+
* dynamically, so check before attempting to free the memory. */
655+
if( pxEventBits->ucStaticallyAllocated == ( uint8_t ) pdFALSE )
649656
{
650-
/* The event group can only have been allocated dynamically - free
651-
* it again. */
652657
vPortFree( pxEventBits );
653658
}
654-
#elif ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
659+
else
655660
{
656-
/* The event group could have been allocated statically or
657-
* dynamically, so check before attempting to free the memory. */
658-
if( pxEventBits->ucStaticallyAllocated == ( uint8_t ) pdFALSE )
659-
{
660-
vPortFree( pxEventBits );
661-
}
662-
else
663-
{
664-
mtCOVERAGE_TEST_MARKER();
665-
}
661+
mtCOVERAGE_TEST_MARKER();
666662
}
667-
#endif /* configSUPPORT_DYNAMIC_ALLOCATION */
668-
}
669-
( void ) xTaskResumeAll();
663+
}
664+
#endif /* configSUPPORT_DYNAMIC_ALLOCATION */
670665
}
666+
( void ) xTaskResumeAll();
671667
}
672668
/*-----------------------------------------------------------*/
673669

0 commit comments

Comments
 (0)