Skip to content

Commit

Permalink
FreeRTOS: CC_ASSERT() that xTaskCreate() succeeds
Browse files Browse the repository at this point in the history
Stacks such as i-link assume that os_thread_create() always succeeds.
Returning NULL is inconsistent with other create() functions as well
as rt-kernel.

See #2363.
  • Loading branch information
fredrikdanielmoller authored and hefloryd committed Sep 16, 2024
1 parent 785a3be commit 4bf20cd
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/freertos/osal.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,18 @@ os_thread_t * os_thread_create (
void * arg)
{
TaskHandle_t xHandle = NULL;
BaseType_t status;

/* stacksize in freertos is not in bytes but in stack depth, it should be
* divided by the stack width */
configSTACK_DEPTH_TYPE stackdepth =
stacksize / sizeof (StackType_t);

if (xTaskCreate (entry, name, stackdepth, arg, priority, &xHandle) == pdPASS)
{
return (os_thread_t *)xHandle;
}
else
{
return NULL;
}
status = xTaskCreate (entry, name, stackdepth, arg, priority, &xHandle);
CC_UNUSED (status);
CC_ASSERT (status == pdPASS);
CC_ASSERT (xHandle != NULL);
return (os_thread_t *)xHandle;
}

os_mutex_t * os_mutex_create (void)
Expand Down

0 comments on commit 4bf20cd

Please sign in to comment.