Thread (3 messages) flat view 3 messages, 3 authors, 2010-06-11

Re: [PATCH 6/6] of/device: populate platform_device (of_device) resource table on allocation

From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Date: 2010-06-11 01:14:36
Also in: linux-devicetree

On Thu, 2010-06-10 at 10:01 -0600, M. Warner Losh wrote:
: Oh, come on. Both constructions are binary equivalent.
: 
: So how can people seriously be with *that* code:
: 
:       dev->resource = (void *)&dev[1];
: 
: which, semantically, is a nonsense and asks for a fix.

It isn't nonsense.  That's just your opinion of it, nothing more.
No, it's dangerously fragile abuse of the C language which loses type
safety etc... It might be correct, but if somebody comes back in 2 year
to change something in that code, the chances of breaking it are higher
than having the type safe:
:       dev_obj->dev.resource = dev_obj->resource;
: 
Variant.

It's also less ugly.
: simply makes sense.

But this requires extra, bogus fields in the structure and creates a
bogus sizeof issue.

There are problems both ways.  Yelling about it isn't going to make
you any more right, or convince me that I'm wrong.  It is an argument
that is at least two decades old... 
Cheers,
Ben.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help