From: charles Date: Thu, 30 Oct 2008 18:25:21 +0000 (+0000) Subject: Clean up a bit of messy code and potential GC hole X-Git-Tag: pre-name-change~265 X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=commitdiff_plain;h=fe72ba1b6536f6b68abb07002653f46b1eae47ad Clean up a bit of messy code and potential GC hole --- diff --git a/yaffs_guts.c b/yaffs_guts.c index e17aa00..eb34115 100644 --- a/yaffs_guts.c +++ b/yaffs_guts.c @@ -12,7 +12,7 @@ */ const char *yaffs_guts_c_version = - "$Id: yaffs_guts.c,v 1.60 2008-10-30 17:58:44 charles Exp $"; + "$Id: yaffs_guts.c,v 1.61 2008-10-30 18:25:21 charles Exp $"; #include "yportenv.h" @@ -3015,6 +3015,7 @@ static int yaffs_GarbageCollectBlock(yaffs_Device * dev, int block) yaffs_VerifyBlock(dev,bi,block); for (chunkInBlock = 0, oldChunk = block * dev->nChunksPerBlock; + retVal == YAFFS_OK && chunkInBlock < dev->nChunksPerBlock && yaffs_StillSomeChunkBits(dev, block); chunkInBlock++, oldChunk++) { @@ -3143,7 +3144,8 @@ static int yaffs_GarbageCollectBlock(yaffs_Device * dev, int block) } } - yaffs_DeleteChunk(dev, oldChunk, markNAND, __LINE__); + if(retVal == YAFFS_OK) + yaffs_DeleteChunk(dev, oldChunk, markNAND, __LINE__); } } @@ -3185,7 +3187,7 @@ static int yaffs_GarbageCollectBlock(yaffs_Device * dev, int block) dev->isDoingGC = 0; - return YAFFS_OK; + return retVal; } /* New garbage collector @@ -3947,35 +3949,15 @@ void yaffs_FlushEntireDeviceCache(yaffs_Device *dev) static yaffs_ChunkCache *yaffs_GrabChunkCacheWorker(yaffs_Device * dev) { int i; - int usage; - int theOne; if (dev->nShortOpCaches > 0) { for (i = 0; i < dev->nShortOpCaches; i++) { if (!dev->srCache[i].object) return &dev->srCache[i]; } - - return NULL; - - theOne = -1; - usage = 0; /* just to stop the compiler grizzling */ - - for (i = 0; i < dev->nShortOpCaches; i++) { - if (!dev->srCache[i].dirty && - ((dev->srCache[i].lastUse < usage && theOne >= 0) || - theOne < 0)) { - usage = dev->srCache[i].lastUse; - theOne = i; - } - } - - - return theOne >= 0 ? &dev->srCache[theOne] : NULL; - } else { - return NULL; } + return NULL; } static yaffs_ChunkCache *yaffs_GrabChunkCache(yaffs_Device * dev)