From patchwork Thu Apr 6 23:31:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Kaehlcke X-Patchwork-Id: 9668643 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7D44160365 for ; Thu, 6 Apr 2017 23:32:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F198285EC for ; Thu, 6 Apr 2017 23:32:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 75A84285B1; Thu, 6 Apr 2017 23:32:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 09739285B1 for ; Thu, 6 Apr 2017 23:32:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932838AbdDFXcF (ORCPT ); Thu, 6 Apr 2017 19:32:05 -0400 Received: from mail-pg0-f53.google.com ([74.125.83.53]:36795 "EHLO mail-pg0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755494AbdDFXcC (ORCPT ); Thu, 6 Apr 2017 19:32:02 -0400 Received: by mail-pg0-f53.google.com with SMTP id g2so48263028pge.3 for ; Thu, 06 Apr 2017 16:32:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Aod+2RPqD3SnX1ZjaWSlkM0epe7PvSLnk4y0HrVrDqQ=; b=TekIqQMGatnrxvK7Vfe14OLA15ztu4/MJ3sH8uWw8MMS8O187+ETvsF+96m3Sh2eaF BT7gFi+0QmoBJTpkskjvLS0okTjG0ka5OC4aFgcFaNiSuOUKxVoPsASuO63UknRZBVGt uapnsw9jchNKKFzOlrarnChf6AMjQiixrf9sGLyOqHqfZOMTaIBvk6AhNNaTeksMDiB8 l1xNJokzpxOJvSZPS3znzwNzrLZuaqhnWoSnmS810cjgYmYmkkjPxXYKu5EKQuCLSK4j bu76U8MvtxDIpEFfiaSUHGKXkl38zF79jFdMkA4i9MrPm41iQr2J/jWQlLoN4PIgBLgC 1UNg== X-Gm-Message-State: AFeK/H22Z8nEZXrFaq8jH1xfpKiJXQTWXZ9ciBHb4CAg/2ea9wFngNI9XlMHTOLppZsKX1Rd X-Received: by 10.84.238.132 with SMTP id v4mr46360413plk.101.1491521521693; Thu, 06 Apr 2017 16:32:01 -0700 (PDT) Received: from mka.mtv.corp.google.com ([172.22.64.162]) by smtp.gmail.com with ESMTPSA id h7sm46916pfc.99.2017.04.06.16.32.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Apr 2017 16:32:01 -0700 (PDT) From: Matthias Kaehlcke To: Johannes Berg , "David S . Miller" Cc: linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, Grant Grundler , Michael Davidson , Greg Hackmann , Matthias Kaehlcke Subject: [PATCH v2] mac80211: Fix clang warning about constant operand in logical operation Date: Thu, 6 Apr 2017 16:31:41 -0700 Message-Id: <20170406233141.123098-1-mka@chromium.org> X-Mailer: git-send-email 2.12.2.715.g7642488e1d-goog Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When clang detects a non-boolean constant in a logical operation it generates a 'constant-logical-operand' warning. In ieee80211_try_rate_control_ops_get() the result of strlen() is used in a logical operation, clang resolves the expression to an (integer) constant at compile time when clang's builtin strlen function is used. Change the condition to check for strlen() > 0 to make the constant operand boolean and thus avoid the warning. Signed-off-by: Matthias Kaehlcke --- Changes in v2: - Changed expression to strlen() > 0 to make constant operand boolean instead of splitting up condition - Updated commit message net/mac80211/rate.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c index 206698bc93f4..694faf6ab574 100644 --- a/net/mac80211/rate.c +++ b/net/mac80211/rate.c @@ -173,9 +173,11 @@ 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); - /* try built-in one if specific alg requested but not found */ - if (!ops && strlen(CONFIG_MAC80211_RC_DEFAULT)) + /* Note: check for > 0 is intentional to avoid clang warning */ + if (!ops && (strlen(CONFIG_MAC80211_RC_DEFAULT) > 0)) + /* try built-in one if specific alg requested but not found */ ops = ieee80211_try_rate_control_ops_get(CONFIG_MAC80211_RC_DEFAULT); + kernel_param_unlock(THIS_MODULE); return ops;