• Johannes Berg's avatar
    locking/barriers: Don't use sizeof(void) in lockless_dereference() · d7127b5e
    Johannes Berg authored
    My previous commit:
    
      112dc0c8 ("locking/barriers: Suppress sparse warnings in lockless_dereference()")
    
    caused sparse to complain that (in radix-tree.h) we use sizeof(void)
    since that rcu_dereference()s a void *.
    
    Really, all we need is to have the expression *p in here somewhere
    to make sure p is a pointer type, and sizeof(*p) was the thing that
    came to my mind first to make sure that's done without really doing
    anything at runtime.
    
    Another thing I had considered was using typeof(*p), but obviously
    we can't just declare a typeof(*p) variable either, since that may
    end up being void. Declaring a variable as typeof(*p)* gets around
    that, and still checks that typeof(*p) is valid, so do that. This
    type construction can't be done for _________p1 because that will
    actually be used and causes sparse address space warnings, so keep
    a separate unused variable for it.
    Reported-by: default avatarFengguang Wu <fengguang.wu@intel.com>
    Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
    Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Paul E . McKenney <paulmck@linux.vnet.ibm.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: kbuild-all@01.org
    Fixes: 112dc0c8 ("locking/barriers: Suppress sparse warnings in lockless_dereference()")
    Link: http://lkml.kernel.org/r/1472192160-4049-1-git-send-email-johannes@sipsolutions.netSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
    d7127b5e
compiler.h 16.4 KB