Merge #1034: Handle queue and task allocation failures before starting sensor work

This commit is contained in:
Michael Sitarzewski
2026-10-06 11:28:24 -05:00
@@ -60,7 +60,16 @@ static void sensor_task(void *arg) {
void app_main(void) {
sensor_queue = xQueueCreate(8, sizeof(sensor_data_t));
xTaskCreate(sensor_task, "sensor", TASK_STACK_SIZE, NULL, TASK_PRIORITY, NULL);
if (sensor_queue == NULL) {
// Never start a task that will send to an invalid queue.
return; // Report allocation failure through the application's fault path.
}
if (xTaskCreate(sensor_task, "sensor", TASK_STACK_SIZE, NULL,
TASK_PRIORITY, NULL) != pdPASS) {
vQueueDelete(sensor_queue);
sensor_queue = NULL;
return; // No task owns the queue; release it before reporting the fault.
}
}
```