[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20170715042022.GA18345@la.guarana.org>
Date: Sat, 15 Jul 2017 00:20:23 -0400
From: Kevin Easton <kevin@...rana.org>
To: Arnd Bergmann <arnd@...db.de>
Cc: Joe Perches <joe@...ches.com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Karsten Keil <isdn@...ux-pingi.de>,
"David S. Miller" <davem@...emloft.net>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Tejun Heo <tj@...nel.org>, Guenter Roeck <linux@...ck-us.net>,
IDE-ML <linux-ide@...r.kernel.org>,
Linux Media Mailing List <linux-media@...r.kernel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
dri-devel <dri-devel@...ts.freedesktop.org>,
Networking <netdev@...r.kernel.org>
Subject: Re: [PATCH 05/14] isdn: isdnloop: suppress a gcc-7 warning
On Fri, Jul 14, 2017 at 12:37:05PM +0200, Arnd Bergmann wrote:
> On Fri, Jul 14, 2017 at 12:08 PM, Joe Perches <joe@...ches.com> wrote:
> > On Fri, 2017-07-14 at 11:25 +0200, Arnd Bergmann wrote:
> >> 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]
...
> > 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
Powered by blists - more mailing lists