Subject: Re: [Cbe-oss-dev] [PATCH] cell: abstract spu management routines

From: Michael Ellerman <[email-masked]>
Date: Wed, 08 Nov 2006 17:28:09 +1100

On Tue, 2006-11-07 at 21:24 -0800, Geoff Levand wrote:
> Michael Ellerman wrote:
> >> +static struct platform_data *platform_data(struct spu *spu)
> >> +{
> >> +	BUG_ON(!spu->platform_data);
> >> +	return (struct platform_data*)spu->platform_data;
> >> +}
> > 
> > I don't see the point of this, why not just grab platform data directly?
> 
> Well, first, it does a check, and second, you can't just grab platform_data,
> you need to always do the cast also. So then, is something like
> '((struct platform_data*)spu->platform_data)->' preferred over
> 'platform_data(spu)->'?

Stephen points out that you shouldn't do the cast at all (inside the
function), it's implied by the return type. And by casting explicitly
you create the potential for the return type and the cast to get out of
sync.

At some point we'll actually read the rest of the patch ;)

cheers

-- 
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person