Skip to content

A complete AI agency at your fingertips - From frontend wizards to Reddit community ninjas, from whimsy injectors to reality checkers. Each agent is a specialized expert with personality, processes, and proven deliverables.

Shell

Handle queue and task allocation failures before starting sensor work

Rudy Celekli2d1fa1c896d7
diff --git a/engineering/engineering-embedded-firmware-engineer.md b/engineering/engineering-embedded-firmware-engineer.md
index 896bca3c..91265956 100644
--- a/engineering/engineering-embedded-firmware-engineer.md
+++ b/engineering/engineering-embedded-firmware-engineer.md
@@ -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.
+ }
}
```