c++/4645: -Wall warning for -1 return on signed long does not make sense

waratah@zip.com.au waratah@zip.com.au
Mon Oct 22 08:16:00 GMT 2001


>Number:         4645
>Category:       c++
>Synopsis:       -Wall warning for -1 return on signed long does not make sense
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Oct 22 08:16:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Ken Foskey
>Release:        gcc  2.95.4
>Organization:
>Environment:
LInux,  debian woody
>Description:
The final return line in this open office 'tools' code generates under -Wall:

/data/office/tools/source/zcodec/zcodec.cxx:195: warning: converting of negative value `-1' to `long unsigned int'

Where does the 'long unsigned int' come from?  The line before it lists 'In method `long int ZCodec::Compress(SvStream &, SvStream &)':'  so it cannot be the return value.


long ZCodec::Decompress( SvStream& rIStm, SvStream& rOStm )
{
	char	err;
	ULONG	nInToRead;
	long	nOldTotal_Out = PZSTREAM->total_out;

	if ( mbFinish )	
		return PZSTREAM->total_out - nOldTotal_Out;

	if ( mbInit == 0 )
	{
		mpIStm = &rIStm;
		mpOStm = &rOStm;
		ImplInitBuf( TRUE );
		PZSTREAM->next_out = mpOutBuf = new BYTE[ PZSTREAM->avail_out = mnOutBufSize ];
	}
	do
	{
		if ( PZSTREAM->avail_out == 0 ) ImplWriteBack();
		if ( PZSTREAM->avail_in == 0 && mnInToRead )
		{		
			nInToRead = ( mnInBufSize > mnInToRead ) ? mnInToRead : mnInBufSize;
			PZSTREAM->avail_in = mpIStm->Read( PZSTREAM->next_in = mpInBuf, nInToRead );
			mnInToRead -= nInToRead;

			if ( mnCompressMethod & ZCODEC_UPDATE_CRC )
				mnCRC = UpdateCRC( mnCRC, mpInBuf, nInToRead );

		}
		err = inflate( PZSTREAM, Z_NO_FLUSH );
		if ( err < 0 )
		{
			mbStatus = FALSE;
			break;
		}
		
	}		
	while ( ( err != Z_STREAM_END)  && ( PZSTREAM->avail_in || mnInToRead ) );
	ImplWriteBack();
	
	if ( err == Z_STREAM_END ) 
		mbFinish = TRUE;	
	return ( mbStatus ) ? PZSTREAM->total_out - nOldTotal_Out : -1;
}

>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-prs mailing list