On Mon, Dec 06, 2010 at 04:52:43PM -0800, Keith Packard wrote: > On Mon, 6 Dec 2010 14:53:17 -0800, James Jones <[email protected]> wrote: > > + SyncCounter *pCounter; > > + > > + assert(!pTrigger->pSync || (SYNC_COUNTER == pTrigger->pSync->type)); > > + > > + pCounter = (SyncCounter *)pTrigger->pSync; > > Btw, I notice you consistently place of the constant on the left side of > the == operator. This isn't common practice in the X server, but I could > grow to like it. Obviously avoids any accidental assignments.
Yeesh, please no. gcc does actually make it fairly hard to get this
wrong; the only way is to use excessive parentheses which arguably
shouldn't be there in the first place:
dani...@tempa:~% cat foo.c && gcc -o /dev/null foo.c
#include <assert.h>
int main(int argc, char *argv[])
{
int i;
assert(0 || i = 3); /* line 5 */
assert(0 || i == 3);
assert(0 || (i = 3));
if (0 || i = 3) /* line 8 */
return 8;
if (0 || (i = 3))
return 10;
if (0 || i == 3)
return 12;
return 0;
}
foo.c: In function ‘main’:
foo.c:5: error: lvalue required as left operand of assignment
foo.c:8: error: lvalue required as left operand of assignment
Cheers,
Daniel
signature.asc
Description: Digital signature
_______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: http://lists.x.org/mailman/listinfo/xorg-devel
