devenum: Fix order of operations bug (Coverity id 709)
david at l8s.co.uk
Wed Sep 10 15:52:02 CDT 2008
On Wed, Sep 10, 2008 at 01:38:03PM -0700, Juan Lang wrote:
> > I'm pretty sure this would come out as:
> > dwMediaTypeSize + (dwMediaTypeSize < (2 ? 1 : dwMediaTypeSize) / 2)
> It doesn't, check the order of operations again.
> > But even if it doesn't, I don't think it'd hurt to be more explicit:
> > dwMediaTypeSize + ((dwMediaTypeSize < 2) ? 1 : (dwMediaTypeSize/2))
> Why use two parentheses when 6 will do, eh? Sorry, I don't agree that
> this is clearer.
Agreed, if you add too many parenthesis it gets difficult to see
where they line up (which some tool to show you).
I get peeved that gcc always warns about && and || - where the order
is obvious and correctly defined.
Blindly putting parenthesis around conditional expressions leads people
dwMediaTypeSize + (dwMediaTypeSize < 2) ? 1 : dwMediaTypeSize / 2
which is unlikely to have the desired effect!
David Laight: david at l8s.co.uk
More information about the wine-devel