xtensa/esp32: Make asprintf and lib_free corresponding

This commit is contained in:
Dong Heng 2023-03-23 14:20:22 +08:00 committed by Petro Karashchenko
parent 00c3463426
commit a51e102a41
8 changed files with 31 additions and 30 deletions

View File

@ -3076,7 +3076,7 @@ static void esp_nvs_close(uint32_t handle)
#ifdef CONFIG_ESP32_WIFI_SAVE_PARAM #ifdef CONFIG_ESP32_WIFI_SAVE_PARAM
struct nvs_adpt *nvs_adpt = (struct nvs_adpt *)handle; struct nvs_adpt *nvs_adpt = (struct nvs_adpt *)handle;
kmm_free(nvs_adpt->index_name); lib_free(nvs_adpt->index_name);
kmm_free(nvs_adpt); kmm_free(nvs_adpt);
#else #else
DEBUGPANIC(); DEBUGPANIC();
@ -3138,7 +3138,7 @@ static int32_t esp_nvs_set_blob(uint32_t handle,
if (ret != -ENOENT) if (ret != -ENOENT)
{ {
wlerr("Failed to unlink %s error=%d\n", dir, ret); wlerr("Failed to unlink %s error=%d\n", dir, ret);
kmm_free(dir); lib_free(dir);
return -1; return -1;
} }
} }
@ -3147,7 +3147,7 @@ static int32_t esp_nvs_set_blob(uint32_t handle,
if (ret < 0) if (ret < 0)
{ {
wlerr("Failed to set open %s\n", dir); wlerr("Failed to set open %s\n", dir);
kmm_free(dir); lib_free(dir);
return -1; return -1;
} }
@ -3155,12 +3155,12 @@ static int32_t esp_nvs_set_blob(uint32_t handle,
if (ret < 0) if (ret < 0)
{ {
wlerr("Failed to write to %s\n", dir); wlerr("Failed to write to %s\n", dir);
kmm_free(dir); lib_free(dir);
file_close(&file); file_close(&file);
return -1; return -1;
} }
kmm_free(dir); lib_free(dir);
file_close(&file); file_close(&file);
return 0; return 0;
@ -3213,11 +3213,11 @@ static int32_t esp_nvs_get_blob(uint32_t handle,
if (ret == -ENOENT) if (ret == -ENOENT)
{ {
wlinfo("No file %s\n", dir); wlinfo("No file %s\n", dir);
kmm_free(dir); lib_free(dir);
return ESP_ERR_NVS_NOT_FOUND; return ESP_ERR_NVS_NOT_FOUND;
} }
wlerr("Failed to get open %s\n", dir); wlerr("Failed to get open %s\n", dir);
kmm_free(dir); lib_free(dir);
return -1; return -1;
} }
@ -3225,7 +3225,7 @@ static int32_t esp_nvs_get_blob(uint32_t handle,
if (ret <= 0) if (ret <= 0)
{ {
wlerr("Failed to write to %s\n", dir); wlerr("Failed to write to %s\n", dir);
kmm_free(dir); lib_free(dir);
file_close(&file); file_close(&file);
return -1; return -1;
} }
@ -3234,7 +3234,7 @@ static int32_t esp_nvs_get_blob(uint32_t handle,
*length = ret; *length = ret;
} }
kmm_free(dir); lib_free(dir);
file_close(&file); file_close(&file);
return 0; return 0;
@ -3279,11 +3279,11 @@ static int32_t esp_nvs_erase_key(uint32_t handle, const char *key)
if (ret < 0) if (ret < 0)
{ {
wlerr("Failed to delete NVS file %s\n", dir); wlerr("Failed to delete NVS file %s\n", dir);
kmm_free(dir); lib_free(dir);
return -1; return -1;
} }
kmm_free(dir); lib_free(dir);
return 0; return 0;
#else #else

View File

@ -2949,7 +2949,7 @@ static void esp_nvs_close(uint32_t handle)
#ifdef CONFIG_ESP32S3_WIFI_SAVE_PARAM #ifdef CONFIG_ESP32S3_WIFI_SAVE_PARAM
struct nvs_adpt *nvs_adpt = (struct nvs_adpt *)handle; struct nvs_adpt *nvs_adpt = (struct nvs_adpt *)handle;
kmm_free(nvs_adpt->index_name); lib_free(nvs_adpt->index_name);
kmm_free(nvs_adpt); kmm_free(nvs_adpt);
#else #else
DEBUGPANIC(); DEBUGPANIC();
@ -3011,7 +3011,7 @@ static int32_t esp_nvs_set_blob(uint32_t handle,
if (ret != -ENOENT) if (ret != -ENOENT)
{ {
wlerr("Failed to unlink %s error=%d\n", dir, ret); wlerr("Failed to unlink %s error=%d\n", dir, ret);
kmm_free(dir); lib_free(dir);
return -1; return -1;
} }
} }
@ -3020,7 +3020,7 @@ static int32_t esp_nvs_set_blob(uint32_t handle,
if (ret < 0) if (ret < 0)
{ {
wlerr("Failed to set open %s\n", dir); wlerr("Failed to set open %s\n", dir);
kmm_free(dir); lib_free(dir);
return -1; return -1;
} }
@ -3028,12 +3028,12 @@ static int32_t esp_nvs_set_blob(uint32_t handle,
if (ret < 0) if (ret < 0)
{ {
wlerr("Failed to write to %s\n", dir); wlerr("Failed to write to %s\n", dir);
kmm_free(dir); lib_free(dir);
file_close(&file); file_close(&file);
return -1; return -1;
} }
kmm_free(dir); lib_free(dir);
file_close(&file); file_close(&file);
return 0; return 0;
@ -3086,11 +3086,11 @@ static int32_t esp_nvs_get_blob(uint32_t handle,
if (ret == -ENOENT) if (ret == -ENOENT)
{ {
wlinfo("No file %s\n", dir); wlinfo("No file %s\n", dir);
kmm_free(dir); lib_free(dir);
return ESP_ERR_NVS_NOT_FOUND; return ESP_ERR_NVS_NOT_FOUND;
} }
wlerr("Failed to get open %s\n", dir); wlerr("Failed to get open %s\n", dir);
kmm_free(dir); lib_free(dir);
return -1; return -1;
} }
@ -3098,7 +3098,7 @@ static int32_t esp_nvs_get_blob(uint32_t handle,
if (ret <= 0) if (ret <= 0)
{ {
wlerr("Failed to write to %s\n", dir); wlerr("Failed to write to %s\n", dir);
kmm_free(dir); lib_free(dir);
file_close(&file); file_close(&file);
return -1; return -1;
} }
@ -3107,7 +3107,7 @@ static int32_t esp_nvs_get_blob(uint32_t handle,
*length = ret; *length = ret;
} }
kmm_free(dir); lib_free(dir);
file_close(&file); file_close(&file);
return 0; return 0;
@ -3152,11 +3152,11 @@ static int32_t esp_nvs_erase_key(uint32_t handle, const char *key)
if (ret < 0) if (ret < 0)
{ {
wlerr("Failed to delete NVS file %s\n", dir); wlerr("Failed to delete NVS file %s\n", dir);
kmm_free(dir); lib_free(dir);
return -1; return -1;
} }
kmm_free(dir); lib_free(dir);
return 0; return 0;
#else #else

View File

@ -725,7 +725,7 @@ static int telnet_close(FAR struct file *filep)
} }
} }
kmm_free(devpath); lib_free(devpath);
} }
for (i = 0; i < CONFIG_TELNET_MAXLCLIENTS; i++) for (i = 0; i < CONFIG_TELNET_MAXLCLIENTS; i++)

View File

@ -357,7 +357,7 @@ static int _inode_search(FAR struct inode_search_s *desc)
"%s/%s", desc->relpath, name); "%s/%s", desc->relpath, name);
if (buffer != NULL) if (buffer != NULL)
{ {
kmm_free(desc->buffer); lib_free(desc->buffer);
desc->buffer = buffer; desc->buffer = buffer;
relpath = buffer; relpath = buffer;
} }

View File

@ -35,6 +35,7 @@
#include <nuttx/kmalloc.h> #include <nuttx/kmalloc.h>
#include <nuttx/fs/fs.h> #include <nuttx/fs/fs.h>
#include <nuttx/lib/lib.h>
/**************************************************************************** /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
@ -58,7 +59,7 @@
{ \ { \
if ((d)->buffer != NULL) \ if ((d)->buffer != NULL) \
{ \ { \
kmm_free((d)->buffer); \ lib_free((d)->buffer); \
(d)->buffer = NULL; \ (d)->buffer = NULL; \
} \ } \
} \ } \

View File

@ -1775,7 +1775,7 @@ static int unionfs_readdir(FAR struct inode *mountpt,
/* Free the allocated relpath */ /* Free the allocated relpath */
kmm_free(relpath); lib_free(relpath);
/* Check for a duplicate */ /* Check for a duplicate */
@ -1862,7 +1862,7 @@ static int unionfs_readdir(FAR struct inode *mountpt,
/* Free the allocated relpath */ /* Free the allocated relpath */
kmm_free(relpath); lib_free(relpath);
} }
} }
} }

View File

@ -449,7 +449,7 @@ static int dir_close(FAR struct file *filep)
/* Release our references on the contained 'root' inode */ /* Release our references on the contained 'root' inode */
inode_release(inode); inode_release(inode);
kmm_free(relpath); lib_free(relpath);
return ret; return ret;
} }

View File

@ -244,7 +244,7 @@ errout:
RELEASE_SEARCH(&newdesc); RELEASE_SEARCH(&newdesc);
if (subdir != NULL) if (subdir != NULL)
{ {
kmm_free(subdir); lib_free(subdir);
} }
return ret; return ret;
@ -429,7 +429,7 @@ errout_with_newsearch:
RELEASE_SEARCH(&newdesc); RELEASE_SEARCH(&newdesc);
if (subdir != NULL) if (subdir != NULL)
{ {
kmm_free(subdir); lib_free(subdir);
} }
return ret; return ret;