X-Git-Url: http://git.cascardo.info/?p=cascardo%2Flinux.git;a=blobdiff_plain;f=include%2Flinux%2Fcompiler.h;h=f1bfa15b6f9b7fd563fa5c281d336895704e606e;hp=86130cded1104d268f0c790ca8341bc5cb5d4ce5;hb=84d69848c97faab0c25aa2667b273404d2e2a64a;hpb=590abbdd273304b55824bcb9ea91840ea375575d diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 86130cded110..f1bfa15b6f9b 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -550,13 +550,14 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s * object's lifetime is managed by something other than RCU. That * "something other" might be reference counting or simple immortality. * - * The seemingly unused void * variable is to validate @p is indeed a pointer - * type. All pointer types silently cast to void *. + * The seemingly unused variable ___typecheck_p validates that @p is + * indeed a pointer type by using a pointer to typeof(*p) as the type. + * Taking a pointer to typeof(*p) again is needed in case p is void *. */ #define lockless_dereference(p) \ ({ \ typeof(p) _________p1 = READ_ONCE(p); \ - __maybe_unused const void * const _________p2 = _________p1; \ + typeof(*(p)) *___typecheck_p __maybe_unused; \ smp_read_barrier_depends(); /* Dependency order vs. p above. */ \ (_________p1); \ })