[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PULL 00/11] Ide patches
From: |
Peter Maydell |
Subject: |
Re: [Qemu-devel] [PULL 00/11] Ide patches |
Date: |
Mon, 18 Sep 2017 19:14:57 +0100 |
On 18 September 2017 at 19:00, Peter Maydell <address@hidden> wrote:
> On 18 September 2017 at 18:55, John Snow <address@hidden> wrote:
>> On 09/16/2017 10:34 AM, Peter Maydell wrote:
>>> Hi; I'm afraid this doesn't build with clang:
>>>
>>> /home/petmay01/linaro/qemu-for-merges/hw/ide/core.c:70:15: error:
>>> comparison of unsigned enum expression >= 0 is always true
>>> [-Werror,-Wtautological-compare]
>>> if (enval >= 0 && enval < IDE_DMA__COUNT) {
>>> ~~~~~ ^ ~
>>> 1 error generated
> I think you could argue that it would at least be helpful
> if clang didn't warn about comparisons that only happen
> to be useless for this particular platform/impdef choice
> but are useful for the same code compiled with a different
> compiler.
A bit of googling and some experimentation reveals that
clang deliberately suppresses this warning in the special
case of comparing against an enum value which happens to
be zero (but not for literal constant zero!). So this will
be fine:
if (enval >= IDE_DMA_READ && enval < IDE_DMA__COUNT)
(or more sensibly you'd want to define an enum constant
for IDE_DMA__FIRST or something rather than relying on
READ being 0.)
(found here:
http://clang-developers.42468.n3.nabble.com/Possibly-invalid-enum-tautology-warning-td3233140.html
)
thanks
-- PMM
- [Qemu-devel] [PULL 01/11] ide: ahci: unparent children buses before freeing their memory, (continued)
- [Qemu-devel] [PULL 01/11] ide: ahci: unparent children buses before freeing their memory, John Snow, 2017/09/15
- [Qemu-devel] [PULL 06/11] ATAPI: Replace DEBUG_IDE_ATAPI with tracing events, John Snow, 2017/09/15
- [Qemu-devel] [PULL 07/11] IDE: replace DEBUG_AIO with trace events, John Snow, 2017/09/15
- [Qemu-devel] [PULL 11/11] AHCI: remove DPRINTF macro, John Snow, 2017/09/15
- [Qemu-devel] [PULL 08/11] AHCI: Replace DPRINTF with trace-events, John Snow, 2017/09/15
- Re: [Qemu-devel] [PULL 00/11] Ide patches, no-reply, 2017/09/15
- Re: [Qemu-devel] [PULL 00/11] Ide patches, Peter Maydell, 2017/09/16