From c781acfc65d4fd58ab019bffe09a238124caeadc Mon Sep 17 00:00:00 2001 From: Alexey Zholtikov Date: Sun, 18 Oct 2026 18:26:44 +0300 Subject: [PATCH] perf: updated error checks --- zh_pcf8574.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/zh_pcf8574.c b/zh_pcf8574.c index 1735592..77e7a0a 100755 --- a/zh_pcf8574.c +++ b/zh_pcf8574.c @@ -238,10 +238,16 @@ esp_err_t zh_pcf8574_deinit(zh_pcf8574_handle_t **handle) { ZH_ERROR_CHECK_CONT(gpio_isr_handler_remove(_interrupt_gpio) == ESP_OK, NULL, "PCF8574 deinitialization failed. Remove GPIO isr handler failed."); ZH_ERROR_CHECK_CONT(gpio_reset_pin(_interrupt_gpio) == ESP_OK, NULL, "PCF8574 deinitialization failed. Reset GPIO failed."); - vTaskDelete(zh_pcf8574); - zh_pcf8574 = NULL; - vSemaphoreDelete(_interrupt_semaphore); - _interrupt_semaphore = NULL; + if (zh_pcf8574 != NULL) + { + vTaskDelete(zh_pcf8574); + zh_pcf8574 = NULL; + } + if (_interrupt_semaphore != NULL) + { + vSemaphoreDelete(_interrupt_semaphore); + _interrupt_semaphore = NULL; + } _interrupt_gpio = GPIO_NUM_MAX; } ZH_ERROR_CHECK(zh_vector_free(&_vector) == ESP_OK, ESP_FAIL, NULL, "PCF8574 deinitialization failed. Free vector failed.");