From aca0035de6e6039f03b4954cdb6187267e1917d9 Mon Sep 17 00:00:00 2001 From: patacongo Date: Mon, 31 Oct 2011 20:23:17 +0000 Subject: 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 --- apps/examples/nxffs/nxffs_main.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'apps/examples') 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 + * Author: Gregory Nutt * * 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 */ -- cgit v1.2.3