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

From: Benjamin Herrenschmidt <[email-masked]>
Date: Fri, 11 Jun 2010 11:14:36 +1000

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.