perf: updated error check
This commit is contained in:
1 parent
ae27426dd0
commit
19e94cfb71
2 files changed
+2
No files matched your search
@@ -152,6 +152,7 @@ extern "C"
|
|||||||
* @return ESP_OK on success
|
* @return ESP_OK on success
|
||||||
* @return ESP_ERR_INVALID_ARG if config or handle is NULL, or parameters are invalid
|
* @return ESP_ERR_INVALID_ARG if config or handle is NULL, or parameters are invalid
|
||||||
* @return ESP_ERR_INVALID_STATE if the encoder is already initialized
|
* @return ESP_ERR_INVALID_STATE if the encoder is already initialized
|
||||||
|
* @return ESP_ERR_NO_MEM if memory allocation fails
|
||||||
* @return ESP_FAIL if resource allocation or peripheral initialization fails
|
* @return ESP_FAIL if resource allocation or peripheral initialization fails
|
||||||
*/
|
*/
|
||||||
esp_err_t zh_encoder_init(const zh_encoder_init_config_t *config, zh_encoder_handle_t **handle);
|
esp_err_t zh_encoder_init(const zh_encoder_init_config_t *config, zh_encoder_handle_t **handle);
|
||||||
|
|||||||
@@ -179,6 +179,7 @@ esp_err_t zh_encoder_init(const zh_encoder_init_config_t *config, zh_encoder_han
|
|||||||
ZH_ERROR_CHECK(config != NULL && handle != NULL, ESP_ERR_INVALID_ARG, NULL, "Encoder initialization failed. Invalid argument.");
|
ZH_ERROR_CHECK(config != NULL && handle != NULL, ESP_ERR_INVALID_ARG, NULL, "Encoder initialization failed. Invalid argument.");
|
||||||
ZH_ERROR_CHECK(*handle == NULL, ESP_ERR_INVALID_STATE, NULL, "Encoder initialization failed. Encoder is already initialized.");
|
ZH_ERROR_CHECK(*handle == NULL, ESP_ERR_INVALID_STATE, NULL, "Encoder initialization failed. Encoder is already initialized.");
|
||||||
*handle = heap_caps_calloc(1, sizeof(zh_encoder_handle_t), MALLOC_CAP_8BIT);
|
*handle = heap_caps_calloc(1, sizeof(zh_encoder_handle_t), MALLOC_CAP_8BIT);
|
||||||
|
ZH_ERROR_CHECK(*handle != NULL, ESP_ERR_NO_MEM, NULL, "Encoder initialization failed. Failed to allocate encoder handle.");
|
||||||
ZH_ERROR_CHECK(_zh_encoder_validate_config(config, *handle) == ESP_OK, ESP_FAIL, heap_caps_free(*handle); *handle = NULL, "Encoder initialization failed. Initial configuration check failed.");
|
ZH_ERROR_CHECK(_zh_encoder_validate_config(config, *handle) == ESP_OK, ESP_FAIL, heap_caps_free(*handle); *handle = NULL, "Encoder initialization failed. Initial configuration check failed.");
|
||||||
if (_vector == NULL)
|
if (_vector == NULL)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user