Wireshark-dev: Re: [Wireshark-dev] [Wireshark-commits] rev 21134:	/trunk/tools/lemon/ /trunk/to
      
      
On Mar 22, 2007, at 4:39 PM, lego@xxxxxxxxxxxxx wrote:
http://anonsvn.wireshark.org/viewvc/viewvc.cgi?view=rev&revision=21134
User: lego
Date: 2007/03/22 11:39 PM
Log:
squelch a warning generated by generated code
The fix works, but for that particular style of signed vs. unsigned  
warning - comparing a signed value against a value computed from  
sizeof's - I slightly prefer to cast the signed value to an  
appropriate unsigned type after it's been shown to be nonnegative:
	if( tokenType>0 && (size_t)tokenType<(sizeof(yyTokenName)/ 
sizeof(yyTokenName[0])) )
(and, in many - most? - of those cases, you have to check that the  
value is nonnegative *anyway*, so that check needs to be added), not  
that it makes a difference in the real world (there probably aren't  
going to be more than 2147483647 token types...).
(Of course, in that case, what I'd *really* prefer would be that  
compilers realized that, in the second comparison in that expression,  
the value of tokenType is always >= 0 (in fact, it's always > 0), so  
there's no need to issue a signed vs. unsigned warning in that case....)