Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1618350

Re: [PATCH] mac80211: Fix clang warning about constant operand in logical operation

From Johannes Berg <johannes@sipsolutions.net>
Newsgroups linux.kernel
Subject Re: [PATCH] mac80211: Fix clang warning about constant operand in logical operation
Date 2017-04-06 23:20 +0200
Message-ID <ttmYV-6fl-5@gated-at.bofh.it> (permalink)
References <ttkNs-4Ff-21@gated-at.bofh.it> <ttl6N-51d-1@gated-at.bofh.it> <ttlgu-54H-27@gated-at.bofh.it> <ttmYV-6fl-7@gated-at.bofh.it> <ttlgu-54H-27@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu, 2017-04-06 at 12:24 -0700, Matthias Kaehlcke wrote:

> I agree that the code looks worse :( I hoped to find a fix using a
> preprocessor condition but wasn't successful.

It's actually easy - just remove the 'default ""' from Kconfig, and
then the symbol won't be defined at all if it doesn't get a proper
value. Then you can ifdef the whole thing.

> Some projects (like Chrome OS) build their kernel with all warnings
> being treated as errors. Besides changing the 'offending' code the
> alternatives are to disable the warning completely or to tell clang
> not to use the builtin(s). IMO changing the code is the preferable
> solution, especially since this is so far the only occurrence of the
> warning that I have encountered.
> 
> I used goto instead of nested ifs since other functions in this file
> use the same pattern. If nested ifs are preferred I can change that.

I don't really buy either argument. The warning is simply bogus - I'm
very surprised you don't hit it with more similar macros or cases, like
for example CONFIG_ENABLED(). Try

	git grep 'IS_ENABLED(' | grep '&&'

and you'll find lots of places that seem like they should trigger this
warning.

You're advocating to make the code worse - not very significantly in
this case, but still - just to quiet a compiler warning.

johannes

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] mac80211: Fix clang warning about constant operand in logical operation Matthias Kaehlcke <mka@chromium.org> - 2017-04-06 21:00 +0200
  Re: [PATCH] mac80211: Fix clang warning about constant operand in  logical operation Johannes Berg <johannes@sipsolutions.net> - 2017-04-06 21:20 +0200
    Re: [PATCH] mac80211: Fix clang warning about constant operand in  logical operation Matthias Kaehlcke <mka@chromium.org> - 2017-04-06 21:30 +0200
      Re: [PATCH] mac80211: Fix clang warning about constant operand in  logical operation Johannes Berg <johannes@sipsolutions.net> - 2017-04-06 23:20 +0200
        Re: [PATCH] mac80211: Fix clang warning about constant operand in  logical operation Matthias Kaehlcke <mka@chromium.org> - 2017-04-07 00:50 +0200
          Re: [PATCH] mac80211: Fix clang warning about constant operand in  logical operation Johannes Berg <johannes@sipsolutions.net> - 2017-04-07 01:00 +0200
            Re: [PATCH] mac80211: Fix clang warning about constant operand in  logical operation Matthias Kaehlcke <mka@chromium.org> - 2017-04-07 01:10 +0200
  RE: [PATCH] mac80211: Fix clang warning about constant operand in  logical operation David Laight <David.Laight@ACULAB.COM> - 2017-04-10 16:20 +0200

csiph-web