Skip to content

Commit 4bf20cd

Browse files
fredrikdanielmollerhefloryd
authored andcommitted
FreeRTOS: CC_ASSERT() that xTaskCreate() succeeds
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.
1 parent 785a3be commit 4bf20cd

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/freertos/osal.c

+6-8
Original file line numberDiff line numberDiff line change
@@ -38,20 +38,18 @@ os_thread_t * os_thread_create (
3838
void * arg)
3939
{
4040
TaskHandle_t xHandle = NULL;
41+
BaseType_t status;
4142

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

47-
if (xTaskCreate (entry, name, stackdepth, arg, priority, &xHandle) == pdPASS)
48-
{
49-
return (os_thread_t *)xHandle;
50-
}
51-
else
52-
{
53-
return NULL;
54-
}
48+
status = xTaskCreate (entry, name, stackdepth, arg, priority, &xHandle);
49+
CC_UNUSED (status);
50+
CC_ASSERT (status == pdPASS);
51+
CC_ASSERT (xHandle != NULL);
52+
return (os_thread_t *)xHandle;
5553
}
5654

5755
os_mutex_t * os_mutex_create (void)

0 commit comments

Comments
 (0)