lkml.org 
[lkml]   [2011]   [Nov]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH 01/62] highmem: mark k[un]map_atomic() with two arguments as deprecated
    Em 27-11-2011 03:26, Cong Wang escreveu:
    > /*
    > * Prevent people trying to call kunmap_atomic() as if it were kunmap()
    > * kunmap_atomic() should get the return value of kmap_atomic, not the page.
    > */
    > -#define kunmap_atomic(addr, args...) \
    > -do { \
    > - BUILD_BUG_ON(__same_type((addr), struct page *)); \
    > - __kunmap_atomic(addr); \
    > -} while (0)
    > +static inline void kunmap_atomic(void *addr)
    > +{
    > + BUILD_BUG_ON(__same_type((addr), struct page *));
    > + __kunmap_atomic(addr);
    > +}
    > +
    > +static inline void __deprecated kunmap_atomic_deprecated(void *addr,
    > + enum km_type km)
    > +{
    > + BUILD_BUG_ON(__same_type((addr), struct page *));
    > + __kunmap_atomic(addr);
    > +}

    This will break the misuse detection of kunmap_atomic (see commit
    597781f3e51f48ef8e67be772196d9e9673752c4).

    kunmap_atomic() _must_ be a macro, so the __same_type can see the type
    the caller used. If you use an inline function, all it will see is a
    void *, even if the caller confused it with kunmap() and passed a struct
    page *.

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


    \
     
     \ /
      Last update: 2011-11-27 13:39    [W:3.734 / U:0.120 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site