Fix another NXFFS write-when-flash-is-full problem

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4075 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2011-10-31 20:23:17 +00:00
parent 2b3f44c717
commit 0e26ab464b

View File

@ -2,7 +2,7 @@
* examples/nxffs/nxffs_main.c * examples/nxffs/nxffs_main.c
* *
* Copyright (C) 2011 Gregory Nutt. All rights reserved. * Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -642,9 +642,17 @@ static int nxffs_delfiles(void)
int i; int i;
int j; int j;
/* How many files should we delete? */ /* Are there any files to be deleted? */
ndel = (rand() % (g_nfiles - g_ndeleted)) + 1; int nfiles = g_nfiles - g_ndeleted;
if (nfiles < 1)
{
return 0;
}
/* Yes... How many files should we delete? */
ndel = (rand() % nfiles) + 1;
/* Now pick which files to delete */ /* Now pick which files to delete */