> It ("C Style and Coding Standards for SunOS") says in section 19:
 > 
 >      Do not default the boolean test for nonzero, i.e.
 >           if (f() != FAIL)
 >      is better than
 >           if (f())
 > 
 > then:
 > 
 >      Never use the boolean negation operator (!) with non-boolean
 >      expressions. In particular, never use it to test for a NULL
 >      pointer or to test for success of the strcmp function, e.g.,
 > 
 >           char *p;
 >           ...
 >           if (!p)                    /* WRONG */
 >                    return;
 >           if (!strcmp(*argv, "-a"))  /* WRONG */
 >                    aflag++;
 > 
 > I'm guessing that's what Garrett was thinking of.

I don't think that applies to testing flag values.  I see a significant
difference between "if (foo())" and "if (foo->bar & MYFLAG)".

-- 
meem
_______________________________________________
driver-discuss mailing list
driver-discuss@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/driver-discuss

Reply via email to