Re: wintrust: Sign-compare warnings fix

2008-12-11 Thread Andrew Talbot
Hi Juan, Juan Lang wrote: > The case I objected to is a curious one. I had a look at K&R's type > promotion rules (2nd edition, section A6.5) and I'm confused what the > compiler is doing here. The if-block is: > > if (pbEncoded[1] + 1 > cbEncoded) > > Rewriting the parenthesized expression a

Re: wintrust: Sign-compare warnings fix

2008-12-11 Thread Juan Lang
Hi Andy, > I was curious to see how this one would fly. I fully take your point, of > course. If it were a good idea, the point would be to reduce the noise when > looking for real sign-compare problems and without introducing a cast. In a > similar vein, quite a lot of warnings are generated by c

Re: wintrust: Sign-compare warnings fix

2008-12-10 Thread Andrew Talbot
Juan Lang wrote: > Hi Andy, > > -if (pbEncoded[1] + 1 > cbEncoded) > +if (pbEncoded[1] + 1U > cbEncoded) > > Is this change necessary? The resulting code is less clear than the > original, IMO. It's clearly a spurious warning: a BYTE (max value > 255) + 1 can't yield a value t

Re: wintrust: Sign-compare warnings fix

2008-12-10 Thread Juan Lang
Hi Andy, -if (pbEncoded[1] + 1 > cbEncoded) +if (pbEncoded[1] + 1U > cbEncoded) Is this change necessary? The resulting code is less clear than the original, IMO. It's clearly a spurious warning: a BYTE (max value 255) + 1 can't yield a value that overflows an unsigned int, so