# HG changeset patch # User charles # Date 1225391121 0 # Node ID 24d738c4d7db50bae1e65e71638c639e434967c6 # Parent bc2b0ab2a7be114cf14d20e74d439fbf5c70bf99 Clean up a bit of messy code and potential GC hole diff --git a/yaffs_guts.c b/yaffs_guts.c --- a/yaffs_guts.c +++ b/yaffs_guts.c @@ -3015,6 +3015,7 @@ static int yaffs_GarbageCollectBlock(yaf 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(yaf } } - yaffs_DeleteChunk(dev, oldChunk, markNAND, __LINE__); + if(retVal == YAFFS_OK) + yaffs_DeleteChunk(dev, oldChunk, markNAND, __LINE__); } } @@ -3185,7 +3187,7 @@ static int yaffs_GarbageCollectBlock(yaf dev->isDoingGC = 0; - return YAFFS_OK; + return retVal; } /* New garbage collector @@ -3947,35 +3949,15 @@ void yaffs_FlushEntireDeviceCache(yaffs_ 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)