lkml.org 
[lkml]   [2021]   [Oct]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [RFC][PATCH] rcu: Use typeof(p) instead of typeof(*p) *
    ----- On Oct 5, 2021, at 3:40 PM, rostedt rostedt@goodmis.org wrote:

    > On Tue, 5 Oct 2021 21:06:36 +0200 (CEST)
    > Jan Engelhardt <jengelh@inai.de> wrote:
    >
    >> On Tuesday 2021-10-05 20:40, Steven Rostedt wrote:
    >> >>
    >> >> >>>> typeof(*p) *________p1 = (typeof(*p) *__force)READ_ONCE(p);
    >> >>
    >> >> #define static_cast(type, expr) ((struct { type x; }){(expr)}.x)
    >> >> typeof(p) p1 = (typeof(p) __force)static_cast(void *, READ_ONCE(p));
    >> >>
    >> >> Let the name not fool you; it's absolutely _not_ the same as C++'s
    >> >> static_cast, but still: it does emit a warning when you do pass an
    >> >> integer, which is better than no warning at all in that case.
    >> >>
    >> >> *flies away*
    >> >
    >> >Are you suggesting I should continue this exercise ;-)
    >>
    >> “After all, why not?”
    >>
    >> typeof(p) p1 = (typeof(p) __force)READ_ONCE(p) +
    >> BUILD_BUG_ON_EXPR(__builtin_classify_type(p) != 5);
    >
    > I may try it, because exposing the structure I want to hide, is pulling out
    > a lot of other crap with it :-p

    I like the static_cast() approach above. It is neat way to validate that the
    argument is a pointer without need to dereference the pointer.

    I would also be open to consider this trick for liburcu's userspace API.

    About the other proposed solution based on __builtin_classify_type, I am
    reluctant to use something designed specifically for varargs in a context
    where they are not used.

    Thanks,

    Mathieu

    --
    Mathieu Desnoyers
    EfficiOS Inc.
    http://www.efficios.com

    \
     
     \ /
      Last update: 2021-10-05 21:50    [W:2.955 / U:0.484 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site