AP_HAL_SITL: check result code of pthread_attr_init

This commit is contained in:
Peter Barker 2020-01-19 22:20:08 +11:00 committed by Andrew Tridgell
parent d5729236e2
commit 9ef23872e0
1 changed files with 4 additions and 2 deletions

View File

@ -323,8 +323,10 @@ bool Scheduler::thread_create(AP_HAL::MemberProc proc, const char *name, uint32_
a->stack_size = stack_size; a->stack_size = stack_size;
a->f[0] = proc; a->f[0] = proc;
a->name = name; a->name = name;
pthread_attr_init(&a->attr); if (pthread_attr_init(&a->attr) != 0) {
goto failed;
}
#if SITL_STACK_CHECKING_ENABLED #if SITL_STACK_CHECKING_ENABLED
if (pthread_attr_setstack(&a->attr, a->stack, alloc_stack) != 0) { if (pthread_attr_setstack(&a->attr, a->stack, alloc_stack) != 0) {
AP_HAL::panic("Failed to set stack of size %u for thread %s", alloc_stack, name); AP_HAL::panic("Failed to set stack of size %u for thread %s", alloc_stack, name);