lkml.org 
[lkml]   [2010]   [May]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] Make kunmap_atomic() harder to misuse
Em 31-05-2010 07:15, Rusty Russell escreveu:
> On Sun, 30 May 2010 01:12:56 pm Andrew Morton wrote:
>> On Fri, 28 May 2010 07:53:13 -0300 Cesar Eduardo Barros<cesarb@cesarb.net> wrote:
>>> +/* Prevent people trying to call kunmap_atomic() as if it were kunmap() */
>>> +struct __kunmap_atomic_dummy {};
>>> +#define kunmap_atomic(addr, idx) do { \
>>> + BUILD_BUG_ON( \
>>> + __builtin_types_compatible_p(typeof(addr), struct page *)&& \
>>> + !__builtin_types_compatible_p(typeof(addr), struct __kunmap_atomic_dummy *)); \
>>> + kunmap_atomic_notypecheck((addr), (idx)); \
>>> + } while (0)
>>
>> We have a little __same_type() helper for this. __must_be_array()
>> should be using it, too.
>
> Yep... but I think BUILD_BUG_ON(__same_type((addr), struct page *)); is
> sufficient; void * is not compatible in my quick tests here.

That is what I get for only reading the manual instead of testing :(

(I only tested the completed patch, not each step along the way.)

I will try it later today and make a new patch if it works as expected.

--
Cesar Eduardo Barros
cesarb@cesarb.net
cesar.barros@gmail.com


\
 
 \ /
  Last update: 2010-05-31 12:47    [W:0.075 / U:0.268 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site