Fix a loop indexing problem in all file system tests

This commit is contained in:
Gregory Nutt 2015-10-10 17:15:15 -06:00
parent b93af2189b
commit a512e7dc1d
3 changed files with 33 additions and 30 deletions

View File

@ -619,10 +619,19 @@ static int fstest_delfiles(void)
int ndx = (rand() % (g_nfiles - g_ndeleted));
/* And delete the next undeleted file after that random index */
/* And delete the next undeleted file after that random index. NOTE
* that the entry at ndx is not checked.
*/
for (j = ndx + 1; j != ndx;)
for (j = ndx + 1; j != ndx; j++)
{
/* Test for wrap-around */
if (j >= CONFIG_EXAMPLES_FSTEST_MAXOPEN)
{
j = 0;
}
file = &g_files[j];
if (file->name && !file->deleted)
{
@ -644,14 +653,6 @@ static int fstest_delfiles(void)
break;
}
}
/* Increment the index and test for wrap-around */
if (++j >= CONFIG_EXAMPLES_FSTEST_MAXOPEN)
{
j = 0;
}
}
}

View File

@ -652,10 +652,19 @@ static int nxffs_delfiles(void)
int ndx = (rand() % (g_nfiles - g_ndeleted));
/* And delete the next undeleted file after that random index */
/* And delete the next undeleted file after that random index. NOTE
* that the entry at ndx is not checked.
*/
for (j = ndx + 1; j != ndx;)
for (j = ndx + 1; j != ndx; j++)
{
/* Test for wrap-around */
if (j >= CONFIG_EXAMPLES_FSTEST_MAXOPEN)
{
j = 0;
}
file = &g_files[j];
if (file->name && !file->deleted)
{
@ -677,14 +686,6 @@ static int nxffs_delfiles(void)
break;
}
}
/* Increment the index and test for wrap-around */
if (++j >= CONFIG_EXAMPLES_NXFFS_MAXOPEN)
{
j = 0;
}
}
}

View File

@ -657,10 +657,19 @@ static int smart_delfiles(void)
int ndx = (rand() % (g_nfiles - g_ndeleted));
/* And delete the next undeleted file after that random index */
/* And delete the next undeleted file after that random index. NOTE
* that the entry at ndx is not checked.
*/
for (j = ndx + 1; j != ndx;)
for (j = ndx + 1; j != ndx; j++)
{
/* Test for wrap-around */
if (j >= CONFIG_EXAMPLES_FSTEST_MAXOPEN)
{
j = 0;
}
file = &g_files[j];
if (file->name && !file->deleted)
{
@ -682,14 +691,6 @@ static int smart_delfiles(void)
break;
}
}
/* Increment the index and test for wrap-around */
if (++j >= CONFIG_EXAMPLES_SMART_MAXOPEN)
{
j = 0;
}
}
}