From: Benjamin Herrenschmidt Subject: Re: [PATCH 6/6] of/device: populate platform_device (of_device) resource table on allocation Date: Fri, 11 Jun 2010 11:14:36 +1000 Message-ID: <1276218876.1962.80.camel@pasglop> References: <20100610.091357.513168276793712624.imp@bsdimp.com> <20100610154741.GA7484@oksana.dev.rtsoft.ru> <20100610.100140.8559628065321695.imp@bsdimp.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20100610.100140.8559628065321695.imp@bsdimp.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linuxppc-dev-bounces+glppe-linuxppc-embedded-2=m.gmane.org@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+glppe-linuxppc-embedded-2=m.gmane.org@lists.ozlabs.org To: "M. Warner Losh" Cc: sfr@canb.auug.org.au, microblaze-uclinux@itee.uq.edu.au, devicetree-discuss@lists.ozlabs.org, jeremy.kerr@canonical.com, linuxppc-dev@lists.ozlabs.org List-Id: devicetree@vger.kernel.org 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.