diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-10-31 20:23:17 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-10-31 20:23:17 +0000 |
commit | aca0035de6e6039f03b4954cdb6187267e1917d9 (patch) | |
tree | 05b374750789b462c791e30da39c5912adbc78f2 /apps/examples/nxffs | |
parent | 1670d2d218ad2dbcf33c53dbce818b8514836f65 (diff) | |
download | nuttx-aca0035de6e6039f03b4954cdb6187267e1917d9.tar.gz nuttx-aca0035de6e6039f03b4954cdb6187267e1917d9.tar.bz2 nuttx-aca0035de6e6039f03b4954cdb6187267e1917d9.zip |
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
Diffstat (limited to 'apps/examples/nxffs')
-rw-r--r-- | apps/examples/nxffs/nxffs_main.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/apps/examples/nxffs/nxffs_main.c b/apps/examples/nxffs/nxffs_main.c index e201f0802..863f8bb43 100644 --- a/apps/examples/nxffs/nxffs_main.c +++ b/apps/examples/nxffs/nxffs_main.c @@ -2,7 +2,7 @@ * examples/nxffs/nxffs_main.c * * 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 * modification, are permitted provided that the following conditions @@ -642,9 +642,17 @@ static int nxffs_delfiles(void) int i; 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 */ |