atomic: strip "const" from variables declared with typeof
commit5927ed846ad17e1cc8e9f60f50486ec418829776
authorPaolo Bonzini <pbonzini@redhat.com>
Tue, 9 Aug 2016 19:02:24 +0000 (9 15:02 -0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 9 Aug 2016 20:57:36 +0000 (9 22:57 +0200)
tree7b57d6b9b2a96f9f93512dc6ee78bd51633197a2
parent9d4cd7b4ed413a1371997ce74da39900b2a8473b
atomic: strip "const" from variables declared with typeof

With the latest clang, we have the following warning:

    /home/pranith/devops/code/qemu/include/qemu/seqlock.h:62:21: warning: passing 'typeof (*&sl->sequence) *' (aka 'const unsigned int *') to parameter of type 'unsigned int *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
        return unlikely(atomic_read(&sl->sequence) != start);
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/pranith/devops/code/qemu/include/qemu/atomic.h:58:25: note: expanded from macro 'atomic_read'
        __atomic_load(ptr, &_val, __ATOMIC_RELAXED);     \
                           ^~~~~

Stripping const is a bit tricky due to promotions, but it is doable
with either C11 _Generic or GCC extensions.  Use the latter.

Reported-by: Pranith Kumar <bobby.prani@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
[pranith: Add conversion for bool type]
Signed-off-by: Pranith Kumar <bobby.prani@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
include/qemu/atomic.h