]> git.baikalelectronics.ru Git - kernel.git/commit
kernel: make READ_ONCE() valid on const arguments
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 20 Feb 2015 23:46:31 +0000 (15:46 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 21 Feb 2015 18:27:33 +0000 (10:27 -0800)
commiteb977e41fe1ca88524698aea8441a970f63d0406
tree62743edeac21a222371f9032fa1f0e59531c38ce
parentab3ba7a9844a661fac455680cf3b7d225d14c57f
kernel: make READ_ONCE() valid on const arguments

The use of READ_ONCE() causes lots of warnings witht he pending paravirt
spinlock fixes, because those ends up having passing a member to a
'const' structure to READ_ONCE().

There should certainly be nothing wrong with using READ_ONCE() with a
const source, but the helper function __read_once_size() would cause
warnings because it would drop the 'const' qualifier, but also because
the destination would be marked 'const' too due to the use of 'typeof'.

Use a union of types in READ_ONCE() to avoid this issue.

Also make sure to use parenthesis around the macro arguments to avoid
possible operator precedence issues.

Tested-by: Ingo Molnar <mingo@kernel.org>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
include/linux/compiler.h