> > I don't think that applies to testing flag values.  I see a significant
 > > difference between "if (foo())" and "if (foo->bar & MYFLAG)".
 > 
 > I'm not sure if the Style Guide makes that difference.  I don't know.  
 > Frankly, this is one of my least favorite rules in the guide, because I 
 > happen to think "if (!foo)" is clearer than "if (foo != 0)".  But I 
 > didn't write the guide, or get to vote on it -- but I do assume that I'm 
 > bound to follow it.
 > 
 > If I've misinterpreted what it says, I'd be happy to be corrected, 
 > because to *my* eyes, I agree with Peter.

I think the proper usage depends on the types involved.  For instance, if
foo() returns an `int', then `if (!foo())' is just wrong.  But if foo()
returns a boolean, then I think `if (!foo())' is considerably better than
`if (foo() == B_FALSE)' or other similar variants.  Of course, `foo->bar &
MYFLAG' doesn't return a boolean, but it's being used as a boolean
operation -- one isn't interested in the resulting value but merely that
the flag is set.  As such, I think `if (foo->bar & MYFLAG)' is best.

--
meem
_______________________________________________
driver-discuss mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/driver-discuss

Reply via email to