[PATCH xserver (v4) 03/10] Make Await SyncTrigger functions generic
Daniel Stone
daniel at fooishbar.org
Tue Dec 7 03:12:14 PST 2010
On Mon, Dec 06, 2010 at 04:52:43PM -0800, Keith Packard wrote:
> On Mon, 6 Dec 2010 14:53:17 -0800, James Jones <jajones at nvidia.com> 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:
daniels at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.x.org/archives/xorg-devel/attachments/20101207/c6cf3f81/attachment-0001.pgp>
More information about the xorg-devel
mailing list