fix SPIFFS_readdir setting errno to SPIFFS_VIS_END

When iteration finishes, spiffs_obj_lu_find_entry_visitor returns
SPIFFS_VIS_END. Previously, SPIFFS_readdir function used to set
errno to this internal error value when readdir reached the end.
Handle this case and add a check into the regression test.
This commit is contained in:
Ivan Grokhotkov
2022-06-01 12:03:32 +02:00
parent 2b73a7fd31
commit 1239341b0d
2 changed files with 3 additions and 0 deletions
+2
View File
@@ -1121,6 +1121,8 @@ struct spiffs_dirent *SPIFFS_readdir(spiffs_DIR *d, struct spiffs_dirent *e) {
d->entry = entry + 1;
e->obj_id &= ~SPIFFS_OBJ_ID_IX_FLAG;
ret = e;
} else if (res == SPIFFS_VIS_END) {
// end of iteration
} else {
d->fs->err_code = res;
}
+1
View File
@@ -439,6 +439,7 @@ TEST(list_dir)
#endif
}
}
TEST_CHECK_EQ(SPIFFS_errno(FS), SPIFFS_OK);
SPIFFS_closedir(&d);
TEST_CHECK(found == file_cnt);