From patchwork Fri Jun 20 21:32:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 4392871 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B5BE89F1D6 for ; Fri, 20 Jun 2014 21:32:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CE3D7203E3 for ; Fri, 20 Jun 2014 21:32:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EAE39203DC for ; Fri, 20 Jun 2014 21:32:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757525AbaFTVcN (ORCPT ); Fri, 20 Jun 2014 17:32:13 -0400 Received: from mail-lb0-f173.google.com ([209.85.217.173]:36135 "EHLO mail-lb0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757400AbaFTVcM (ORCPT ); Fri, 20 Jun 2014 17:32:12 -0400 Received: by mail-lb0-f173.google.com with SMTP id s7so2695874lbd.4 for ; Fri, 20 Jun 2014 14:32:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=9TW33u0MlqdFUaCQtjMLPmoMmp7cLQQh8VBp3iOBe3E=; b=Aa3Nv28e8Ty2YK0bdIF6AGMi8xMVXHSLIy69ikwCBP8rV1tSEQXnVyz3aowMB0Bn/u iU7q6asy11bzCEVCAEQsvh3PvqstPiDsM6I8FjOk8l4QDuQ8yq296bWL2vAEeWMhvi2b Hp8RE8J4xhKTP0pxCisufckHpYoiApXq8M7zB6VqzxaJVlx6aQqcrTzsw/XH1eJ72pRo mCxXbzX+voQhgcLV2CmyCdMM0377/3T3Iri940ScWSf13i9vo8rKJMQ2t9dyN1STwlqN 8Q13GALmNecDxseKjyxj20EBALjw2yZsycIpeUJoKPAf/gkHXHuesovooqcai8ltyod4 yeUg== X-Gm-Message-State: ALoCoQkgP9Aj8Dqxv1ytDFp2SBncFJBRmrEtL3HRMG0H+bYUrS5rU1sg4U8Ii1gRhvuIC4XIkcv1 X-Received: by 10.152.5.230 with SMTP id v6mr4225342lav.33.1403299930808; Fri, 20 Jun 2014 14:32:10 -0700 (PDT) Received: from spencer.imf.au.dk ([130.225.20.51]) by mx.google.com with ESMTPSA id a13sm7363785lbo.43.2014.06.20.14.32.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Jun 2014 14:32:10 -0700 (PDT) From: Rasmus Villemoes To: Brett Rudley , Arend van Spriel Cc: linux-wireless@vger.kernel.org, brcm80211-dev-list@broadcom.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Rasmus Villemoes Subject: [PATCH] net/wireless/brcm80211/brcmfmac: Make return type reflect actual semantics Date: Fri, 20 Jun 2014 23:32:03 +0200 Message-Id: <1403299923-21533-1-git-send-email-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 1.7.10.4 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Applying ++ to a bool is equivalent to setting it true, regardless of its initial value (bools are not uint1_t). Hence the function wl_get_vif_state_all can only ever return true/false. The only in-tree caller uses its return value as a boolean. So update its return type, and since the list traversal and bit testing have no side effects, just return true immediately. Signed-off-by: Rasmus Villemoes --- Notes: Alternatively, if the function is supposed to return a count, the one-line fix would be - bool result = 0; + u32 result = 0; drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c | 7 +++---- drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.h | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c index d8fa276..ec5f8c5 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c @@ -5625,16 +5625,15 @@ enum nl80211_iftype brcmf_cfg80211_get_iftype(struct brcmf_if *ifp) return wdev->iftype; } -u32 wl_get_vif_state_all(struct brcmf_cfg80211_info *cfg, unsigned long state) +bool wl_get_vif_state_all(struct brcmf_cfg80211_info *cfg, unsigned long state) { struct brcmf_cfg80211_vif *vif; - bool result = 0; list_for_each_entry(vif, &cfg->vif_list, list) { if (test_bit(state, &vif->sme_state)) - result++; + return true; } - return result; + return false; } static inline bool vif_event_equals(struct brcmf_cfg80211_vif_event *event, diff --git a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.h b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.h index 283c525..c702e4e 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.h +++ b/drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.h @@ -477,7 +477,7 @@ const struct brcmf_tlv * brcmf_parse_tlvs(const void *buf, int buflen, uint key); u16 channel_to_chanspec(struct brcmu_d11inf *d11inf, struct ieee80211_channel *ch); -u32 wl_get_vif_state_all(struct brcmf_cfg80211_info *cfg, unsigned long state); +bool wl_get_vif_state_all(struct brcmf_cfg80211_info *cfg, unsigned long state); void brcmf_cfg80211_arm_vif_event(struct brcmf_cfg80211_info *cfg, struct brcmf_cfg80211_vif *vif); bool brcmf_cfg80211_vif_event_armed(struct brcmf_cfg80211_info *cfg);