From d1b76d13bb4dfcc46b898a4a2d8decf2298d1194 Mon Sep 17 00:00:00 2001 From: Felipe Neves Date: Fri, 20 Dec 2019 13:27:30 -0300 Subject: [PATCH] exp_expression_with_stack: added check for null pointer after obtaining a mutex in test --- components/esp_common/include/esp_expression_with_stack.h | 2 +- components/newlib/test/test_shared_stack_printf.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/components/esp_common/include/esp_expression_with_stack.h b/components/esp_common/include/esp_expression_with_stack.h index afaf43d0f4..3aa12a2538 100644 --- a/components/esp_common/include/esp_expression_with_stack.h +++ b/components/esp_common/include/esp_expression_with_stack.h @@ -29,7 +29,7 @@ */ #define ESP_EXECUTE_EXPRESSION_WITH_STACK(lock, stack, stack_size, expression) \ ({ \ - if(lock && stack && stack_size) { \ + if (lock && stack && stack_size) { \ uint32_t backup; \ xSemaphoreTake(lock, portMAX_DELAY); \ StackType_t *top_of_stack = esp_switch_stack_setup(stack, stack_size);\ diff --git a/components/newlib/test/test_shared_stack_printf.c b/components/newlib/test/test_shared_stack_printf.c index 5daa248a25..9b020f5815 100644 --- a/components/newlib/test/test_shared_stack_printf.c +++ b/components/newlib/test/test_shared_stack_printf.c @@ -22,6 +22,8 @@ TEST_CASE("test printf using shared buffer stack", "[newlib]") TEST_ASSERT(shared_stack != NULL); SemaphoreHandle_t printf_lock = xSemaphoreCreateMutex(); + TEST_ASSERT_NOT_NULL(printf_lock); + ESP_EXECUTE_EXPRESSION_WITH_STACK(printf_lock, shared_stack,8192,printf("Executing this printf from external stack! \n")); ESP_EXECUTE_EXPRESSION_WITH_STACK(printf_lock, shared_stack,8192,another_external_stack_function()); vSemaphoreDelete(printf_lock);