fs/spiffs: Fix bad check for return value. In NuttX all values greater than or equeal to 0 are successes.
This commit is contained in:
parent
1273f727c0
commit
2d2dd5e9e3
@ -139,7 +139,7 @@ int sim_bringup(void)
|
||||
#ifdef CONFIG_RAMMTD
|
||||
/* Create a RAM MTD device if configured */
|
||||
|
||||
ramstart = (FAR uint8_t *)kmm_malloc(32 * 1024);
|
||||
ramstart = (FAR uint8_t *)kmm_malloc(128 * 1024);
|
||||
if (ramstart == NULL)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Allocation for RAM MTD failed\n");
|
||||
@ -148,7 +148,7 @@ int sim_bringup(void)
|
||||
{
|
||||
/* Initialized the RAM MTD */
|
||||
|
||||
FAR struct mtd_dev_s *mtd = rammtd_initialize(ramstart, 32 * 1024);
|
||||
FAR struct mtd_dev_s *mtd = rammtd_initialize(ramstart, 128 * 1024);
|
||||
if (mtd == NULL)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: rammtd_initialize failed\n");
|
||||
|
@ -2556,7 +2556,7 @@ int spiffs_object_modify(FAR struct spiffs_s *fs,
|
||||
/* Delete original data page */
|
||||
|
||||
ret = spiffs_page_delete(fs, orig_data_pgndx);
|
||||
if (ret != OK)
|
||||
if (ret < 0)
|
||||
{
|
||||
ferr("ERROR: spiffs_page_delete() failed: %d\n", ret);
|
||||
break;
|
||||
@ -2939,7 +2939,7 @@ int spiffs_object_truncate(FAR struct spiffs_s *fs,
|
||||
/* Delete full data page */
|
||||
|
||||
ret = spiffs_page_data_check(fs, fobj, data_pgndx, data_spndx);
|
||||
if (ret != SPIFFS_ERR_DELETED && ret != OK &&
|
||||
if (ret != SPIFFS_ERR_DELETED && ret < 0 &&
|
||||
ret != SPIFFS_ERR_INDEX_REF_FREE)
|
||||
{
|
||||
ferr("ERROR: Failed to validate data pgndx=%d\n", ret);
|
||||
|
@ -1114,9 +1114,14 @@ int spiffs_gc_check(FAR struct spiffs_s *fs, off_t len)
|
||||
SPIFFS_OBJ_LOOKUP_PAGES(fs)) * (SPIFFS_GEO_BLOCK_COUNT(fs) - 2) -
|
||||
fs->stats_p_allocated - fs->stats_p_deleted;
|
||||
|
||||
spiffs_gcinfo("len=%ld free_blocks=%lu\n free_pages=%ld",
|
||||
(long)len, (unsigned long)fs->free_blocksm,
|
||||
(long)free_pages);
|
||||
|
||||
if (fs->free_blocks > 3 &&
|
||||
(int32_t)len < free_pages * (int32_t)SPIFFS_DATA_PAGE_SIZE(fs))
|
||||
{
|
||||
spiffs_gcinfo("Sufficient free space is available Do nothing.\n");
|
||||
return OK;
|
||||
}
|
||||
|
||||
@ -1225,7 +1230,7 @@ int spiffs_gc_check(FAR struct spiffs_s *fs, off_t len)
|
||||
SPIFFS_OBJ_LOOKUP_PAGES(fs)) * (SPIFFS_GEO_BLOCK_COUNT(fs) - 2) -
|
||||
fs->stats_p_allocated - fs->stats_p_deleted;
|
||||
|
||||
if ((int32_t) len > free_pages * (int32_t) SPIFFS_DATA_PAGE_SIZE(fs))
|
||||
if ((int32_t) len > free_pages * (int32_t)SPIFFS_DATA_PAGE_SIZE(fs))
|
||||
{
|
||||
ret = -ENOSPC;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user