From: David Laight <David.Laight@ACULAB.COM>
To: "'Matthias Kaehlcke'" <mka@chromium.org>,
Johannes Berg <johannes@sipsolutions.net>,
"David S . Miller" <davem@davemloft.net>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
Grant Grundler <grundler@chromium.org>,
Michael Davidson <md@google.com>,
Greg Hackmann <ghackmann@google.com>
Subject: RE: [PATCH] mac80211: Fix clang warning about constant operand in logical operation
Date: Mon, 10 Apr 2017 14:12:00 +0000 [thread overview]
Message-ID: <063D6719AE5E284EB5DD2968C1650D6DCFFCA9CE@AcuExch.aculab.com> (raw)
In-Reply-To: <20170406185633.91065-1-mka@chromium.org>
From: Matthias Kaehlcke
> Sent: 06 April 2017 19:57
> Clang raises a warning about the expression 'strlen(CONFIG_XXX)' being
> used in a logical operation. Clangs' builtin strlen function resolves the
> expression to a constant at compile time, which causes clang to generate
> a 'constant-logical-operand' warning.
>
> Split the if statement in two to avoid using the const expression in a
> logical operation.
>
> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
> ---
> net/mac80211/rate.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
> index 206698bc93f4..68ff202d6380 100644
> --- a/net/mac80211/rate.c
> +++ b/net/mac80211/rate.c
> @@ -173,9 +173,14 @@ ieee80211_rate_control_ops_get(const char *name)
> /* try default if specific alg requested but not found */
> ops = ieee80211_try_rate_control_ops_get(ieee80211_default_rc_algo);
>
> + if (ops)
> + goto unlock;
> +
> /* try built-in one if specific alg requested but not found */
> - if (!ops && strlen(CONFIG_MAC80211_RC_DEFAULT))
> + if (strlen(CONFIG_MAC80211_RC_DEFAULT))
> ops = ieee80211_try_rate_control_ops_get(CONFIG_MAC80211_RC_DEFAULT);
> +
> +unlock:
Using the result of strlen() as a boolean should itself be a compilation error.
You could change to code to the equivalent:
if (!ops && CONFIG_MAC80211_RC_DEFAULT[0])
ops = ...
David
prev parent reply other threads:[~2017-04-10 14:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-06 18:56 Matthias Kaehlcke
2017-04-06 19:11 ` Johannes Berg
2017-04-06 19:24 ` Matthias Kaehlcke
2017-04-06 21:12 ` Johannes Berg
2017-04-06 22:42 ` Matthias Kaehlcke
2017-04-06 22:51 ` Johannes Berg
2017-04-06 23:07 ` Matthias Kaehlcke
2017-04-10 14:12 ` David Laight [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=063D6719AE5E284EB5DD2968C1650D6DCFFCA9CE@AcuExch.aculab.com \
--to=david.laight@aculab.com \
--cc=davem@davemloft.net \
--cc=ghackmann@google.com \
--cc=grundler@chromium.org \
--cc=johannes@sipsolutions.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=md@google.com \
--cc=mka@chromium.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®