LWN.net Logo

The timer API: size or type safety?

The timer API: size or type safety?

Posted Dec 8, 2006 19:42 UTC (Fri) by jzbiciak (✭ supporter ✭, #5246)
In reply to: The timer API: size or type safety? by giraffedata
Parent article: The timer API: size or type safety?

Are you certain? Let's look at that closely:

    typeof(*data) *p = data;
    timer->function = (void (*)(void *)) func;
    timer->data = (void *) p;
    (void)(0 && (func(p), 0));

I guess your statement is that the last line, (func(p)) could be rewritten as (func(data)) instead. I can see that.


(Log in to post comments)

The timer API: size or type safety?

Posted Jan 3, 2007 19:48 UTC (Wed) by rjbell4 (guest, #35764) [Link]

The reason you wouldn't necessarily do that is that "data" may actually be an expression that has a side effect, so you don't want to reference it twice.

The timer API: size or type safety?

Posted Jan 3, 2007 19:59 UTC (Wed) by jzbiciak (✭ supporter ✭, #5246) [Link]

So, I guess typeof(*data) doesn't evaluate data then? I guess that makes sense.

The timer API: size or type safety?

Posted Jan 3, 2007 20:01 UTC (Wed) by jzbiciak (✭ supporter ✭, #5246) [Link]

Actually, hold on... (0 && func(data)) shouldn't evaluate data a second time under any circumstances anyway.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds