Message ID | 20221105093916.8255-1-straube.linux@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp905311wru; Sat, 5 Nov 2022 03:00:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM49Wvr3r9umgKwHE4nfRIosPVUQTmuygRZHUlSVx1d/R8k2vZAUHmKP2xNd3YrXxfmxAEtH X-Received: by 2002:a17:906:3281:b0:7ae:624:99a1 with SMTP id 1-20020a170906328100b007ae062499a1mr251610ejw.550.1667642440495; Sat, 05 Nov 2022 03:00:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667642440; cv=none; d=google.com; s=arc-20160816; b=g2v5yKTBg5Vr+klLewuOBIwLruzhvjtQVAkrNr9o5rCsRjx9L03HMlQ57UR2MQIav1 W3C1zIWfRjiF4MEaRynPp5Hybm8/X70ACmYUtGstzsIHogIamIV5BTPnsTu83kGDOtWu WaebFMw9nTgKckl3axmFa9RV4iH4Z3wLRQBNYsraulC4vkkxmPIWHG4PDmHWxd3bmVH9 MkpYmTJs/Syflu54b2nFPgk1OA6bZc4/HlWqI9Crlbw1It3YQz3J258dW5YQ6aykbH16 sDrM2BxO7Sy+xEsHFjc3grFWfF15xcgiKvW7oVAe+Up/kU8WelVoT3fGqVspaQXzRESk cUOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=UxXjh/HXZsln6nQHph//YT1hNRabli6WZS407CAMang=; b=krLPXVwWGeMomBD/u0O7N1wMItItp8qprxebfnS62RlbNbOFiNXceiDF2+rdxrok/a Rz4TcPX/+YXo5Yg5LbU6HvejQKJTkn7WoW19CkEZNgZwGX9J0OJogPEASWvX220fChc6 F81N0crSw7hHsDMx4gocmAB7Vog2GfbYjjGdeM/JzvryJwBSDM5mg83+6GWurqdplkJE ZlpL7ruzo4Z753+qSBGjT8WRnw1ifvGy8FyFn+h0+5ggsyv///UmEi410MGot7nJSycV Olxb+9g6SMCfiI/ebZ//MOBxESJVYPgM5NRzFXFSFY43iYJoRZFF6bXDq/6V70gj34qX Pp6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=f4IyhMYO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bd1-20020a056402206100b0045c2e7e5532si1770735edb.585.2022.11.05.03.00.15; Sat, 05 Nov 2022 03:00:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=f4IyhMYO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229555AbiKEJjh (ORCPT <rfc822;hjfbswb@gmail.com> + 99 others); Sat, 5 Nov 2022 05:39:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229485AbiKEJjf (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 5 Nov 2022 05:39:35 -0400 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54C541019 for <linux-kernel@vger.kernel.org>; Sat, 5 Nov 2022 02:39:33 -0700 (PDT) Received: by mail-ej1-x62c.google.com with SMTP id 13so18927706ejn.3 for <linux-kernel@vger.kernel.org>; Sat, 05 Nov 2022 02:39:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=UxXjh/HXZsln6nQHph//YT1hNRabli6WZS407CAMang=; b=f4IyhMYOp03CFxrRgNeKLddDWgkauptTZj7+gxlIkLrb9whUDtzfgfIpy6ONi/MiqS tSLL/T3aazcnY69xJ943JhUSfAu7lLzTpFI0i5CqB5EkzAlz1+3WeQHxi79ohmXLs00X eSqMGfp2Xjxkrw3p2wvUlmy0XwDYaqaTbnXLXcLuT3+DrjZ6ePaYuykFs/Y7AJ5kcYd3 u1b2F50Q53it1RkhDz+eD89oyIxrg+N4vMyJq3x/ppSoOpqbpBosEpC12MAjSXy1Wh/p +xWU66UJrWo7XPjQh+JtvSAxYlpSNybXeYlCkSmbvmj6v+EDgqc95aW/+PnIeXo55EaE wv2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=UxXjh/HXZsln6nQHph//YT1hNRabli6WZS407CAMang=; b=LLswxjdzPWIEe7v1adgjIOW3JhTjDOccCRSUt+n56z3ZPLFfw6OjrpZ+rp7T8wnnob vf2J6n3uFxR1XY5/HUyn6+K+mJx5Xd22OCYCFSzIjF2EZt3MQSaaeLyffBelEqHCp1y7 pYfu5Mdrr0LUVH5lv4kYM93jMDl7TlzC9tGegVOEly+IBfvSrN7cgH05H+qftyv/lEr5 LtVAY9/oxnW78kagsbcq3NX6s5np5OpBRE5PBe/Iv+MA6Yc71PT1yxc5a/d/tSdMa4w6 EaqWJRCWVslkXPkGc8+T3c3xxFBiahfPstMO1yCSYkHvDptW4l+9IcqUQY9Y50s+saxT x8pQ== X-Gm-Message-State: ACrzQf2J9S5EcNo2gMctKt2f68K7svggiXZ8ebtHVjoxwyPjj7Qh+4Yi 8DVHC7mxo48/GELh5IPWlLI= X-Received: by 2002:a17:907:a40f:b0:7ad:b9b7:582c with SMTP id sg15-20020a170907a40f00b007adb9b7582cmr36685920ejc.347.1667641171813; Sat, 05 Nov 2022 02:39:31 -0700 (PDT) Received: from localhost.localdomain (ip5f5abba7.dynamic.kabel-deutschland.de. [95.90.187.167]) by smtp.gmail.com with ESMTPSA id lj18-20020a170906f9d200b007adade0e9easm677549ejb.85.2022.11.05.02.39.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Nov 2022 02:39:31 -0700 (PDT) From: Michael Straube <straube.linux@gmail.com> To: gregkh@linuxfoundation.org Cc: Larry.Finger@lwfinger.net, phil@philpotter.co.uk, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Michael Straube <straube.linux@gmail.com> Subject: [PATCH] staging: r8188eu: convert three functions to bool Date: Sat, 5 Nov 2022 10:39:16 +0100 Message-Id: <20221105093916.8255-1-straube.linux@gmail.com> X-Mailer: git-send-email 2.38.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748649839901936013?= X-GMAIL-MSGID: =?utf-8?q?1748649839901936013?= |
Series |
staging: r8188eu: convert three functions to bool
|
|
Commit Message
Michael Straube
Nov. 5, 2022, 9:39 a.m. UTC
The functions
is_client_associated_to_ap()
is_client_associated_to_ibss()
is_IBSS_empty()
return boolean values. Convert their return type to bool and replace
_FAIL, which is defined as 0, with false. Another step to get rid of
_SUCCESS / _FAIL.
Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
drivers/staging/r8188eu/core/rtw_wlan_util.c | 18 +++++++++---------
drivers/staging/r8188eu/include/rtw_mlme_ext.h | 6 +++---
2 files changed, 12 insertions(+), 12 deletions(-)
Comments
On Sat, Nov 05, 2022 at 10:39:16AM +0100, Michael Straube wrote: > The functions > > is_client_associated_to_ap() > is_client_associated_to_ibss() > is_IBSS_empty() > > return boolean values. Convert their return type to bool and replace > _FAIL, which is defined as 0, with false. Another step to get rid of > _SUCCESS / _FAIL. > > Signed-off-by: Michael Straube <straube.linux@gmail.com> > --- > drivers/staging/r8188eu/core/rtw_wlan_util.c | 18 +++++++++--------- > drivers/staging/r8188eu/include/rtw_mlme_ext.h | 6 +++--- > 2 files changed, 12 insertions(+), 12 deletions(-) > > diff --git a/drivers/staging/r8188eu/core/rtw_wlan_util.c b/drivers/staging/r8188eu/core/rtw_wlan_util.c > index e50631848cab..c95438a12b59 100644 > --- a/drivers/staging/r8188eu/core/rtw_wlan_util.c > +++ b/drivers/staging/r8188eu/core/rtw_wlan_util.c > @@ -331,35 +331,35 @@ u16 get_beacon_interval(struct wlan_bssid_ex *bss) > return le16_to_cpu(val); > } > > -int is_client_associated_to_ap(struct adapter *padapter) > +bool is_client_associated_to_ap(struct adapter *padapter) > { > struct mlme_ext_priv *pmlmeext; > struct mlme_ext_info *pmlmeinfo; > > if (!padapter) > - return _FAIL; > + return false; > > pmlmeext = &padapter->mlmeextpriv; > pmlmeinfo = &pmlmeext->mlmext_info; > > if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE)) > return true; > - else > - return _FAIL; > + > + return false; > } > > -int is_client_associated_to_ibss(struct adapter *padapter) > +bool is_client_associated_to_ibss(struct adapter *padapter) > { > struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; > struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; > > if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE)) > return true; > - else > - return _FAIL; > + > + return false; > } > > -int is_IBSS_empty(struct adapter *padapter) > +bool is_IBSS_empty(struct adapter *padapter) > { > unsigned int i; > struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; > @@ -367,7 +367,7 @@ int is_IBSS_empty(struct adapter *padapter) > > for (i = IBSS_START_MAC_ID; i < NUM_STA; i++) { > if (pmlmeinfo->FW_sta_info[i].status == 1) > - return _FAIL; > + return false; > } > return true; > } > diff --git a/drivers/staging/r8188eu/include/rtw_mlme_ext.h b/drivers/staging/r8188eu/include/rtw_mlme_ext.h > index e234a3b9af6f..7652e72a03f4 100644 > --- a/drivers/staging/r8188eu/include/rtw_mlme_ext.h > +++ b/drivers/staging/r8188eu/include/rtw_mlme_ext.h > @@ -432,9 +432,9 @@ void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, > u8 *get_my_bssid(struct wlan_bssid_ex *pnetwork); > u16 get_beacon_interval(struct wlan_bssid_ex *bss); > > -int is_client_associated_to_ap(struct adapter *padapter); > -int is_client_associated_to_ibss(struct adapter *padapter); > -int is_IBSS_empty(struct adapter *padapter); > +bool is_client_associated_to_ap(struct adapter *padapter); > +bool is_client_associated_to_ibss(struct adapter *padapter); > +bool is_IBSS_empty(struct adapter *padapter); > > unsigned char check_assoc_AP(u8 *pframe, uint len); > > -- > 2.38.0 > Hi Michael, Thanks for the patch. Just my personal opinion, but I would prefer to keep the return type as int, and have 0 for success and then _FAIL replaced with an appropriate error code depending on the circumstance, (e.g. -ENOMEM). This is generally the convention elsewhere in the kernel. Others may not agree though. All the best, Phil
On Sat, Nov 05, 2022 at 11:06:56AM +0000, Phillip Potter wrote: > On Sat, Nov 05, 2022 at 10:39:16AM +0100, Michael Straube wrote: > > The functions > > > > is_client_associated_to_ap() > > is_client_associated_to_ibss() > > is_IBSS_empty() > > > > return boolean values. Convert their return type to bool and replace > > _FAIL, which is defined as 0, with false. Another step to get rid of > > _SUCCESS / _FAIL. > > > > Signed-off-by: Michael Straube <straube.linux@gmail.com> > > --- > > drivers/staging/r8188eu/core/rtw_wlan_util.c | 18 +++++++++--------- > > drivers/staging/r8188eu/include/rtw_mlme_ext.h | 6 +++--- > > 2 files changed, 12 insertions(+), 12 deletions(-) > > > > diff --git a/drivers/staging/r8188eu/core/rtw_wlan_util.c b/drivers/staging/r8188eu/core/rtw_wlan_util.c > > index e50631848cab..c95438a12b59 100644 > > --- a/drivers/staging/r8188eu/core/rtw_wlan_util.c > > +++ b/drivers/staging/r8188eu/core/rtw_wlan_util.c > > @@ -331,35 +331,35 @@ u16 get_beacon_interval(struct wlan_bssid_ex *bss) > > return le16_to_cpu(val); > > } > > > > -int is_client_associated_to_ap(struct adapter *padapter) > > +bool is_client_associated_to_ap(struct adapter *padapter) > > { > > struct mlme_ext_priv *pmlmeext; > > struct mlme_ext_info *pmlmeinfo; > > > > if (!padapter) > > - return _FAIL; > > + return false; > > > > pmlmeext = &padapter->mlmeextpriv; > > pmlmeinfo = &pmlmeext->mlmext_info; > > > > if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE)) > > return true; > > - else > > - return _FAIL; > > + > > + return false; > > } > > > > -int is_client_associated_to_ibss(struct adapter *padapter) > > +bool is_client_associated_to_ibss(struct adapter *padapter) > > { > > struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; > > struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; > > > > if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE)) > > return true; > > - else > > - return _FAIL; > > + > > + return false; > > } > > > > -int is_IBSS_empty(struct adapter *padapter) > > +bool is_IBSS_empty(struct adapter *padapter) > > { > > unsigned int i; > > struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; > > @@ -367,7 +367,7 @@ int is_IBSS_empty(struct adapter *padapter) > > > > for (i = IBSS_START_MAC_ID; i < NUM_STA; i++) { > > if (pmlmeinfo->FW_sta_info[i].status == 1) > > - return _FAIL; > > + return false; > > } > > return true; > > } > > diff --git a/drivers/staging/r8188eu/include/rtw_mlme_ext.h b/drivers/staging/r8188eu/include/rtw_mlme_ext.h > > index e234a3b9af6f..7652e72a03f4 100644 > > --- a/drivers/staging/r8188eu/include/rtw_mlme_ext.h > > +++ b/drivers/staging/r8188eu/include/rtw_mlme_ext.h > > @@ -432,9 +432,9 @@ void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, > > u8 *get_my_bssid(struct wlan_bssid_ex *pnetwork); > > u16 get_beacon_interval(struct wlan_bssid_ex *bss); > > > > -int is_client_associated_to_ap(struct adapter *padapter); > > -int is_client_associated_to_ibss(struct adapter *padapter); > > -int is_IBSS_empty(struct adapter *padapter); > > +bool is_client_associated_to_ap(struct adapter *padapter); > > +bool is_client_associated_to_ibss(struct adapter *padapter); > > +bool is_IBSS_empty(struct adapter *padapter); > > > > unsigned char check_assoc_AP(u8 *pframe, uint len); > > > > -- > > 2.38.0 > > > > Hi Michael, > > Thanks for the patch. Just my personal opinion, but I would prefer to > keep the return type as int, and have 0 for success and then _FAIL > replaced with an appropriate error code depending on the circumstance, > (e.g. -ENOMEM). This is generally the convention elsewhere in the > kernel. Others may not agree though. For functions that are just returning true/false like this (and the function name is something like "is_foo()"), a boolean type is fine and makes more sense as you will only check it in an "if ()" statement block like how these are being used. However, these function names are horrible for being in the global namespace, but that's a totally different issue that can be fixed up in a later patch. thanks, greg k-h
On 11/5/22 10:39, Michael Straube wrote: > The functions > > is_client_associated_to_ap() > is_client_associated_to_ibss() > is_IBSS_empty() > > return boolean values. Convert their return type to bool and replace > _FAIL, which is defined as 0, with false. Another step to get rid of > _SUCCESS / _FAIL. > > Signed-off-by: Michael Straube <straube.linux@gmail.com> > --- > drivers/staging/r8188eu/core/rtw_wlan_util.c | 18 +++++++++--------- > drivers/staging/r8188eu/include/rtw_mlme_ext.h | 6 +++--- > 2 files changed, 12 insertions(+), 12 deletions(-) > > diff --git a/drivers/staging/r8188eu/core/rtw_wlan_util.c b/drivers/staging/r8188eu/core/rtw_wlan_util.c > index e50631848cab..c95438a12b59 100644 > --- a/drivers/staging/r8188eu/core/rtw_wlan_util.c > +++ b/drivers/staging/r8188eu/core/rtw_wlan_util.c > @@ -331,35 +331,35 @@ u16 get_beacon_interval(struct wlan_bssid_ex *bss) > return le16_to_cpu(val); > } > > -int is_client_associated_to_ap(struct adapter *padapter) > +bool is_client_associated_to_ap(struct adapter *padapter) > { > struct mlme_ext_priv *pmlmeext; > struct mlme_ext_info *pmlmeinfo; > > if (!padapter) > - return _FAIL; > + return false; > > pmlmeext = &padapter->mlmeextpriv; > pmlmeinfo = &pmlmeext->mlmext_info; > > if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE)) > return true; > - else > - return _FAIL; > + > + return false; > } > > -int is_client_associated_to_ibss(struct adapter *padapter) > +bool is_client_associated_to_ibss(struct adapter *padapter) > { > struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; > struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; > > if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE)) > return true; > - else > - return _FAIL; > + > + return false; > } > > -int is_IBSS_empty(struct adapter *padapter) > +bool is_IBSS_empty(struct adapter *padapter) > { > unsigned int i; > struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; > @@ -367,7 +367,7 @@ int is_IBSS_empty(struct adapter *padapter) > > for (i = IBSS_START_MAC_ID; i < NUM_STA; i++) { > if (pmlmeinfo->FW_sta_info[i].status == 1) > - return _FAIL; > + return false; > } > return true; > } > diff --git a/drivers/staging/r8188eu/include/rtw_mlme_ext.h b/drivers/staging/r8188eu/include/rtw_mlme_ext.h > index e234a3b9af6f..7652e72a03f4 100644 > --- a/drivers/staging/r8188eu/include/rtw_mlme_ext.h > +++ b/drivers/staging/r8188eu/include/rtw_mlme_ext.h > @@ -432,9 +432,9 @@ void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, > u8 *get_my_bssid(struct wlan_bssid_ex *pnetwork); > u16 get_beacon_interval(struct wlan_bssid_ex *bss); > > -int is_client_associated_to_ap(struct adapter *padapter); > -int is_client_associated_to_ibss(struct adapter *padapter); > -int is_IBSS_empty(struct adapter *padapter); > +bool is_client_associated_to_ap(struct adapter *padapter); > +bool is_client_associated_to_ibss(struct adapter *padapter); > +bool is_IBSS_empty(struct adapter *padapter); > > unsigned char check_assoc_AP(u8 *pframe, uint len); > Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com> # Edimax N150
On Sat, 2022-11-05 at 10:39 +0100, Michael Straube wrote: > The functions > > is_client_associated_to_ap() > is_client_associated_to_ibss() > is_IBSS_empty() > > return boolean values. Convert their return type to bool and replace > _FAIL, which is defined as 0, with false. Another step to get rid of > _SUCCESS / _FAIL. yay. > diff --git a/drivers/staging/r8188eu/core/rtw_wlan_util.c b/drivers/staging/r8188eu/core/rtw_wlan_util.c [] > +bool is_client_associated_to_ap(struct adapter *padapter) > { > struct mlme_ext_priv *pmlmeext; > struct mlme_ext_info *pmlmeinfo; > > if (!padapter) > - return _FAIL; > + return false; > > pmlmeext = &padapter->mlmeextpriv; > pmlmeinfo = &pmlmeext->mlmext_info; > > if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE)) > return true; > - else > - return _FAIL; > + > + return false; instead of if (foo) return true; return false; These could be: return (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE); > +bool is_client_associated_to_ibss(struct adapter *padapter) > { > struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; > struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; > > if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE)) > return true; > - else > - return _FAIL; > + > + return false; and return (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE);
On 11/5/22 12:25, Greg KH wrote: > However, these function names are horrible for being in the global > namespace, but that's a totally different issue that can be fixed up in > a later patch. > I'll send a patch to address that after this patch is accepted. Thanks, Michael
On 11/6/22 09:58, Joe Perches wrote: > On Sat, 2022-11-05 at 10:39 +0100, Michael Straube wrote: >> The functions >> >> is_client_associated_to_ap() >> is_client_associated_to_ibss() >> is_IBSS_empty() >> >> return boolean values. Convert their return type to bool and replace >> _FAIL, which is defined as 0, with false. Another step to get rid of >> _SUCCESS / _FAIL. > > yay. > >> diff --git a/drivers/staging/r8188eu/core/rtw_wlan_util.c b/drivers/staging/r8188eu/core/rtw_wlan_util.c > [] >> +bool is_client_associated_to_ap(struct adapter *padapter) >> { >> struct mlme_ext_priv *pmlmeext; >> struct mlme_ext_info *pmlmeinfo; >> >> if (!padapter) >> - return _FAIL; >> + return false; >> >> pmlmeext = &padapter->mlmeextpriv; >> pmlmeinfo = &pmlmeext->mlmext_info; >> >> if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE)) >> return true; >> - else >> - return _FAIL; >> + >> + return false; > > instead of > > if (foo) > return true; > return false; > > These could be: > > return (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && > ((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE); > >> +bool is_client_associated_to_ibss(struct adapter *padapter) >> { >> struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; >> struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; >> >> if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE)) >> return true; >> - else >> - return _FAIL; >> + >> + return false; > > and > > return (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && > ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE); > > I'll keep this in mind for a future patch. Thanks, Michael
diff --git a/drivers/staging/r8188eu/core/rtw_wlan_util.c b/drivers/staging/r8188eu/core/rtw_wlan_util.c index e50631848cab..c95438a12b59 100644 --- a/drivers/staging/r8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/r8188eu/core/rtw_wlan_util.c @@ -331,35 +331,35 @@ u16 get_beacon_interval(struct wlan_bssid_ex *bss) return le16_to_cpu(val); } -int is_client_associated_to_ap(struct adapter *padapter) +bool is_client_associated_to_ap(struct adapter *padapter) { struct mlme_ext_priv *pmlmeext; struct mlme_ext_info *pmlmeinfo; if (!padapter) - return _FAIL; + return false; pmlmeext = &padapter->mlmeextpriv; pmlmeinfo = &pmlmeext->mlmext_info; if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE)) return true; - else - return _FAIL; + + return false; } -int is_client_associated_to_ibss(struct adapter *padapter) +bool is_client_associated_to_ibss(struct adapter *padapter) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE)) return true; - else - return _FAIL; + + return false; } -int is_IBSS_empty(struct adapter *padapter) +bool is_IBSS_empty(struct adapter *padapter) { unsigned int i; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -367,7 +367,7 @@ int is_IBSS_empty(struct adapter *padapter) for (i = IBSS_START_MAC_ID; i < NUM_STA; i++) { if (pmlmeinfo->FW_sta_info[i].status == 1) - return _FAIL; + return false; } return true; } diff --git a/drivers/staging/r8188eu/include/rtw_mlme_ext.h b/drivers/staging/r8188eu/include/rtw_mlme_ext.h index e234a3b9af6f..7652e72a03f4 100644 --- a/drivers/staging/r8188eu/include/rtw_mlme_ext.h +++ b/drivers/staging/r8188eu/include/rtw_mlme_ext.h @@ -432,9 +432,9 @@ void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, u8 *get_my_bssid(struct wlan_bssid_ex *pnetwork); u16 get_beacon_interval(struct wlan_bssid_ex *bss); -int is_client_associated_to_ap(struct adapter *padapter); -int is_client_associated_to_ibss(struct adapter *padapter); -int is_IBSS_empty(struct adapter *padapter); +bool is_client_associated_to_ap(struct adapter *padapter); +bool is_client_associated_to_ibss(struct adapter *padapter); +bool is_IBSS_empty(struct adapter *padapter); unsigned char check_assoc_AP(u8 *pframe, uint len);