2012.07.06 20:07 "Re: [Tiff] Challenge to properly eliminate warning", by Olivier Paquet
On Fri, Jul 6, 2012 at 3:28 PM, Bob Friesenhahn <bfriesen@simple.dallas.tx.us> wrote:
With libtiff CVS, GCC 4.7.0 produces this remaining warning when
compiling the library:
../libtiff/tif_dirread.c: In function 'TIFFFetchNormalTag':
../libtiff/tif_dirread.c:4770:23: warning: 'data' may be used uninitialized in this function [-Wmaybe-uninitialized]
It would be easy to quench this warning the easy way but I think that
it would mask an error in the error handling logic. I have not yet
found the origin of the error. It is useful to find the origin of the
problem so that a proper error may be returned rather than using
canned wrong data.
From similar problems in other code, I suspect it comes from all the code of the form:
err=TIFFReadDirEntryLong(tif,dp,&data);
if (err==TIFFReadDirEntryErrOk)
{
if (!TIFFSetField(tif,dp->tdir_tag,data))
return(0);
}
We rely on the fact that data is always initialized when
TIFFReadDirEntryLong returns no error. gcc most likely does not understand such complex logic. It will figure that data is "not always initialized" by the function and then later "potentially used".
Olivier