Re: [Yaffs] Some notes on possible bugs

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Charles Manning
Date:  
To: yaffs
Subject: Re: [Yaffs] Some notes on possible bugs
Thanx Sergey

Both of these are, I believe, benign but should be fixed anyway because:
1) The compiler complains.
2) They look dangerous.

On Wednesday 27 July 2005 12:28, Sergey Kubushyn wrote:
> Here they are (all for YAFFS2):
>
> FIRST ONE:
>
> === Cut ===
> fs/yaffs2/yaffs_guts.c: In function `yaffs_FlushFilesChunkCache':
> fs/yaffs2/yaffs_guts.c:3426: warning: 'lowest' might be used uninitialized
> in this function === Cut ===
>
> It IS serious. The fragment is:
>
> === Cut ===
> if(!cache ||  dev->srCache[i].chunkId < lowest)
>     {
>         cache = &dev->srCache[i];
>         lowest = cache->chunkId;
>     }
> === Cut ===


If lowest has not yet been initialised, then cache will be NULL. Therefore in
the !cache will be true and the lowest will not be tested. In the if(),
lowest only gets tested after lowest has been set.

>
> and "lowest" is NOT initialised before that "if".
>
>
> SECOND ONE:
>
> === Cut ===
> fs/yaffs2/yaffs_guts.c: In function `yaffs_GutsInitialise':
> fs/yaffs2/yaffs_guts.c:4941: warning: 'startIterator' might be used
> uninitialized in this function fs/yaffs2/yaffs_guts.c:4942: warning:
> 'endIterator' might be used uninitialized in this function === Cut ===
>
> The fragment is:
>
> === Cut ===
>     // Now scan the blocks looking at the data.
>     if(dev->isYaffs2)
>     {
>         startIterator = 0;
>         endIterator = nBlocksToScan-1;
>         T(YAFFS_TRACE_SCAN_DEBUG,(TSTR("%d blocks to be scanned" > 

TENDSTR),nBlocksToScan)); }
>
>
>     // For each block.... backwards
>     for(blockIterator = endIterator; blockIterator >= startIterator;
> blockIterator--) {
> === Cut ===


Backward scanning is only used by yaff2 (when dev->isYaffs2 is true).
Therefore they will always get tested.

This should really be cleaned up by removing the isYaffs2 test.


> And yes, both those "iterators" are NOT initialised on entry to the "for"
> cycle if "dev->isYaffs2" is zero (i.e. YAFFS1). And that cycle is performed
> in any case.
>
> I think somebody who knows what the appropriate code is supposed to do
> should look into that and fix it asap.



Thanx

-- Charles