fix(wifi_provisioning): fix var declarations inside switch for clang

This commit is contained in:
Ivan Grokhotkov 2024-07-12 12:16:07 +02:00
parent 728136a91d
commit c921824230
No known key found for this signature in database
GPG Key ID: 1E050E141B280628

View File

@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -41,7 +41,7 @@ static esp_err_t prov_start(protocomm_t *pc, void *config)
protocomm_ble_config_t *ble_config = (protocomm_ble_config_t *) config;
#if defined(CONFIG_WIFI_PROV_BLE_BONDING)
ble_config->ble_bonding = 1;
ble_config->ble_bonding = 1;
#endif
#if defined(CONFIG_WIFI_PROV_BLE_SEC_CONN) || defined(CONFIG_BT_BLUEDROID_ENABLED)
@ -183,7 +183,7 @@ static esp_err_t set_config_endpoint(void *config, const char *endpoint_name, ui
}
protocomm_ble_name_uuid_t *lookup_table = (
realloc(ble_config->nu_lookup, (ble_config->nu_lookup_count + 1) * sizeof(protocomm_ble_name_uuid_t)));
realloc(ble_config->nu_lookup, (ble_config->nu_lookup_count + 1) * sizeof(protocomm_ble_name_uuid_t)));
if (!lookup_table) {
ESP_LOGE(TAG, "Error allocating memory for EP-UUID lookup table");
return ESP_ERR_NO_MEM;
@ -200,35 +200,34 @@ static esp_err_t set_config_endpoint(void *config, const char *endpoint_name, ui
void wifi_prov_scheme_ble_event_cb_free_btdm(void *user_data, wifi_prov_cb_event_t event, void *event_data)
{
switch (event) {
case WIFI_PROV_INIT:
case WIFI_PROV_INIT: {
#ifdef CONFIG_BT_CONTROLLER_ENABLED
esp_err_t err;
/* Release BT memory, as we need only BLE */
err = esp_bt_mem_release(ESP_BT_MODE_CLASSIC_BT);
if (err != ESP_OK) {
ESP_LOGE(TAG, "bt_mem_release of classic BT failed %d", err);
} else {
ESP_LOGI(TAG, "BT memory released");
}
/* Release BT memory, as we need only BLE */
esp_err_t err = esp_bt_mem_release(ESP_BT_MODE_CLASSIC_BT);
if (err != ESP_OK) {
ESP_LOGE(TAG, "bt_mem_release of classic BT failed %d", err);
} else {
ESP_LOGI(TAG, "BT memory released");
}
#endif
break;
case WIFI_PROV_DEINIT:
break;
}
case WIFI_PROV_DEINIT: {
#ifndef CONFIG_WIFI_PROV_KEEP_BLE_ON_AFTER_PROV
#ifdef CONFIG_BT_CONTROLLER_ENABLED
/* Release memory used by BLE and Bluedroid host stack */
err = esp_bt_mem_release(ESP_BT_MODE_BTDM);
if (err != ESP_OK) {
ESP_LOGE(TAG, "bt_mem_release of BTDM failed %d", err);
} else {
ESP_LOGI(TAG, "BTDM memory released");
}
/* Release memory used by BLE and Bluedroid host stack */
esp_err_t err = esp_bt_mem_release(ESP_BT_MODE_BTDM);
if (err != ESP_OK) {
ESP_LOGE(TAG, "bt_mem_release of BTDM failed %d", err);
} else {
ESP_LOGI(TAG, "BTDM memory released");
}
#endif
#endif
break;
default:
break;
break;
}
default:
break;
}
}
@ -236,21 +235,21 @@ void wifi_prov_scheme_ble_event_cb_free_btdm(void *user_data, wifi_prov_cb_event
void wifi_prov_scheme_ble_event_cb_free_bt(void *user_data, wifi_prov_cb_event_t event, void *event_data)
{
switch (event) {
case WIFI_PROV_INIT:
case WIFI_PROV_INIT: {
#ifdef CONFIG_BT_CONTROLLER_ENABLED
esp_err_t err;
/* Release BT memory, as we need only BLE */
err = esp_bt_mem_release(ESP_BT_MODE_CLASSIC_BT);
if (err != ESP_OK) {
ESP_LOGE(TAG, "bt_mem_release of classic BT failed %d", err);
} else {
ESP_LOGI(TAG, "BT memory released");
}
esp_err_t err;
/* Release BT memory, as we need only BLE */
err = esp_bt_mem_release(ESP_BT_MODE_CLASSIC_BT);
if (err != ESP_OK) {
ESP_LOGE(TAG, "bt_mem_release of classic BT failed %d", err);
} else {
ESP_LOGI(TAG, "BT memory released");
}
#endif
break;
default:
break;
break;
}
default:
break;
}
}
@ -258,23 +257,23 @@ void wifi_prov_scheme_ble_event_cb_free_bt(void *user_data, wifi_prov_cb_event_t
void wifi_prov_scheme_ble_event_cb_free_ble(void *user_data, wifi_prov_cb_event_t event, void *event_data)
{
switch (event) {
case WIFI_PROV_DEINIT:
case WIFI_PROV_DEINIT: {
#ifndef CONFIG_WIFI_PROV_KEEP_BLE_ON_AFTER_PROV
#ifdef CONFIG_BT_CONTROLLER_ENABLED
esp_err_t err;
/* Release memory used by BLE stack */
err = esp_bt_mem_release(ESP_BT_MODE_BLE);
if (err != ESP_OK) {
ESP_LOGE(TAG, "bt_mem_release of BLE failed %d", err);
} else {
ESP_LOGI(TAG, "BLE memory released");
}
esp_err_t err;
/* Release memory used by BLE stack */
err = esp_bt_mem_release(ESP_BT_MODE_BLE);
if (err != ESP_OK) {
ESP_LOGE(TAG, "bt_mem_release of BLE failed %d", err);
} else {
ESP_LOGI(TAG, "BLE memory released");
}
#endif
#endif
break;
default:
break;
break;
}
default:
break;
}
}