Re: [PATCH 05/14] isdn: isdnloop: suppress a gcc-7 warning
From: Kevin Easton <hidden>
Date: 2017-07-15 04:20:25
Also in:
dri-devel, linux-ide, linux-media, lkml
From: Kevin Easton <hidden>
Date: 2017-07-15 04:20:25
Also in:
dri-devel, linux-ide, linux-media, lkml
On Fri, Jul 14, 2017 at 12:37:05PM +0200, Arnd Bergmann wrote:
On Fri, Jul 14, 2017 at 12:08 PM, Joe Perches [off-list ref] wrote:quoted
On Fri, 2017-07-14 at 11:25 +0200, Arnd Bergmann wrote:quoted
We test whether a bit is set in a mask here, which is correct but gcc warns about it as it thinks it might be confusing: drivers/isdn/isdnloop/isdnloop.c:412:37: error: ?: using integer constants in boolean context, the expression will always evaluate to 'true' [-Werror=int-in-bool-context]
...
quoted
Perhaps this is a logic defect and should be: if (!(card->flags & ((channel) ? ISDNLOOP_FLAGS_B2ACTIVE : ISDNLOOP_FLAGS_B1ACTIVE)))Yes, good catch. I had thought about it for a bit whether that would be the answer, but come to the wrong conclusion on my own. Note that the version you suggested will still have the warning, so I think it needs to be
It shouldn't - the warning is for using an integer *constant* in boolean
context, but the result of & isn't a constant and should be fine.
!(flags & mask) is a very common idiom.
- Kevin