[PATCH RFC 092/111] staging: etnaviv: convert to_etnaviv_bo() to real function

Christian Gmeiner christian.gmeiner at gmail.com
Sun Apr 5 12:29:57 PDT 2015


2015-04-02 18:29 GMT+02:00 Russell King - ARM Linux <linux at arm.linux.org.uk>:
> On Thu, Apr 02, 2015 at 05:30:34PM +0200, Lucas Stach wrote:
>> This provides a bit more type safety.
>>
>> Signed-off-by: Lucas Stach <l.stach at pengutronix.de>
>> ---
>>  drivers/staging/etnaviv/etnaviv_gem.h | 7 ++++++-
>>  1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/staging/etnaviv/etnaviv_gem.h b/drivers/staging/etnaviv/etnaviv_gem.h
>> index cfade337d4db..fadd5198b3e8 100644
>> --- a/drivers/staging/etnaviv/etnaviv_gem.h
>> +++ b/drivers/staging/etnaviv/etnaviv_gem.h
>> @@ -75,7 +75,12 @@ struct etnaviv_gem_object {
>>
>>       struct etnaviv_gem_userptr userptr;
>>  };
>> -#define to_etnaviv_bo(x) container_of(x, struct etnaviv_gem_object, base)
>> +
>> +static inline
>> +struct etnaviv_gem_object *to_etnaviv_bo(struct drm_gem_object *obj)
>> +{
>> +     return container_of(obj, struct etnaviv_gem_object, base);
>> +}
>
> I've always wondered about patches like this, and wondered how they're
> supposed to be more type safe.
>
> The only thing which I can see is that the inline function will warn if
> you pass it a const or volatile pointer, whereas container_of() will
> only warn if it's passed a volatile pointer.  Apart from that, I don't
> see any difference between the two.

Eclipse CDT is happier with functions then macros in some case. I have
no opinion
about this patch.

--
Christian Gmeiner, MSc

https://soundcloud.com/christian-gmeiner


More information about the dri-devel mailing list