qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] gic: avoid a warning from clang


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH] gic: avoid a warning from clang
Date: Mon, 24 Sep 2012 15:56:25 +0100

On 24 September 2012 14:22, Peter Maydell <address@hidden> wrote:
> On 23 September 2012 17:33, Blue Swirl <address@hidden> wrote:
>> Avoid this warning:
>>   CC    arm-softmmu/hw/arm/../arm_gic.o
>> /src/qemu/hw/arm/../arm_gic.c:432:17: error: implicit truncation from 
>> 'unsigned int' to bitfield changes value from 4294967040 to 0 
>> [-Werror,-Wconstant-conversion]
>>                 GIC_CLEAR_PENDING(irq + i, ALL_CPU_MASK);
>>                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> /src/qemu/hw/arm/../arm_gic_internal.h:43:62: note: expanded from:
>> #define GIC_CLEAR_PENDING(irq, cm) s->irq_state[irq].pending &= ~(cm)
>>                                                              ^  ~~~~~
>>
>> 4294967040 is 0xffffff00 and field 'pending' is effectively 8 bits
>> wide, so the masking has no effect except for avoiding the warning.
>
> foo &= ~SOME_FLAGS; is an entirely legitimate and common C idiom,
> and I think clang is being overexuberant in warning here: we should
> disable this warning instead of working around it in the code.

Also, what version of clang are you using? I don't see this warning
either with MacOS X "Apple clang version 4.0 (tags/Apple/clang-421.0.60)
(based on LLVM 3.1svn)" or with "Ubuntu clang version 3.0-6ubuntu3
(tags/RELEASE_30/final) (based on LLVM 3.0)".

-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]