linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: rtl8192e: cleanup if statements
@ 2022-09-25 12:50 Valentin Vidic
  2022-09-25 20:47 ` Philipp Hortmann
  0 siblings, 1 reply; 2+ messages in thread
From: Valentin Vidic @ 2022-09-25 12:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Philipp Hortmann, linux-staging, linux-kernel, Valentin Vidic

Fix checkpatch warnings for if statements in rtl_wx.c

Signed-off-by: Valentin Vidic <vvidic@valentin-vidic.from.hr>
---
 drivers/staging/rtl8192e/rtl8192e/rtl_wx.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
index bfb963768fc3..2db98d4ddb1b 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
@@ -313,7 +313,7 @@ static int _rtl92e_wx_get_range(struct net_device *dev,
 	/* ~130 Mb/s real (802.11n) */
 	range->throughput = 130 * 1000 * 1000;
 
-	if (priv->rf_set_sens != NULL)
+	if (priv->rf_set_sens)
 		/* signal level threshold range */
 		range->sensitivity = priv->max_sens;
 
@@ -395,7 +395,7 @@ static int _rtl92e_wx_set_scan(struct net_device *dev,
 	rt_state = priv->rtllib->eRFPowerState;
 	if (!priv->up)
 		return -ENETDOWN;
-	if (priv->rtllib->LinkDetectInfo.bBusyTraffic == true)
+	if (priv->rtllib->LinkDetectInfo.bBusyTraffic)
 		return -EAGAIN;
 
 	if (wrqu->data.flags & IW_SCAN_THIS_ESSID) {
@@ -582,9 +582,9 @@ static int _rtl92e_wx_set_frag(struct net_device *dev,
 	if (priv->hw_radio_off)
 		return 0;
 
-	if (wrqu->frag.disabled)
+	if (wrqu->frag.disabled) {
 		priv->rtllib->fts = DEFAULT_FRAG_THRESHOLD;
-	else {
+	} else {
 		if (wrqu->frag.value < MIN_FRAG_THRESHOLD ||
 		    wrqu->frag.value > MAX_FRAG_THRESHOLD)
 			return -EINVAL;
@@ -821,7 +821,7 @@ static int _rtl92e_wx_get_sens(struct net_device *dev,
 {
 	struct r8192_priv *priv = rtllib_priv(dev);
 
-	if (priv->rf_set_sens == NULL)
+	if (!priv->rf_set_sens)
 		return -1; /* we have not this support for this radio */
 	wrqu->sens.value = priv->sens;
 	return 0;
@@ -839,7 +839,7 @@ static int _rtl92e_wx_set_sens(struct net_device *dev,
 		return 0;
 
 	mutex_lock(&priv->wx_mutex);
-	if (priv->rf_set_sens == NULL) {
+	if (!priv->rf_set_sens) {
 		err = -1; /* we have not this support for this radio */
 		goto exit;
 	}
@@ -882,7 +882,7 @@ static int _rtl92e_wx_set_encode_ext(struct net_device *dev,
 		u8 idx = 0, alg = 0, group = 0;
 
 		if ((encoding->flags & IW_ENCODE_DISABLED) ||
-		     ext->alg == IW_ENCODE_ALG_NONE) {
+		    ext->alg == IW_ENCODE_ALG_NONE) {
 			ieee->pairwise_key_type = ieee->group_key_type
 						= KEY_TYPE_NA;
 			rtl92e_cam_reset(dev);
@@ -919,7 +919,7 @@ static int _rtl92e_wx_set_encode_ext(struct net_device *dev,
 					 key, 0);
 		} else {
 			if ((ieee->pairwise_key_type == KEY_TYPE_CCMP) &&
-			     ieee->pHTInfo->bCurrentHTSupport)
+			    ieee->pHTInfo->bCurrentHTSupport)
 				rtl92e_writeb(dev, 0x173, 1);
 			rtl92e_set_key(dev, 4, idx, alg,
 				       (u8 *)ieee->ap_mac_addr, 0, key);
@@ -993,7 +993,7 @@ static int _rtl92e_wx_get_gen_ie(struct net_device *dev,
 	struct r8192_priv *priv = rtllib_priv(dev);
 	struct rtllib_device *ieee = priv->rtllib;
 
-	if (ieee->wpa_ie_len == 0 || ieee->wpa_ie == NULL) {
+	if (ieee->wpa_ie_len == 0 || !ieee->wpa_ie) {
 		data->data.length = 0;
 		return 0;
 	}
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] staging: rtl8192e: cleanup if statements
  2022-09-25 12:50 [PATCH] staging: rtl8192e: cleanup if statements Valentin Vidic
@ 2022-09-25 20:47 ` Philipp Hortmann
  0 siblings, 0 replies; 2+ messages in thread
From: Philipp Hortmann @ 2022-09-25 20:47 UTC (permalink / raw)
  To: Valentin Vidic, Greg Kroah-Hartman; +Cc: linux-staging, linux-kernel

On 9/25/22 14:50, Valentin Vidic wrote:
> Fix checkpatch warnings for if statements in rtl_wx.c
I would like to have a more precise description.
> 
> Signed-off-by: Valentin Vidic <vvidic@valentin-vidic.from.hr>
> ---
>   drivers/staging/rtl8192e/rtl8192e/rtl_wx.c | 18 +++++++++---------
>   1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
> index bfb963768fc3..2db98d4ddb1b 100644
> --- a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
> +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
> @@ -313,7 +313,7 @@ static int _rtl92e_wx_get_range(struct net_device *dev,
>   	/* ~130 Mb/s real (802.11n) */
>   	range->throughput = 130 * 1000 * 1000;
>   
> -	if (priv->rf_set_sens != NULL)
> +	if (priv->rf_set_sens)
OK
>   		/* signal level threshold range */
>   		range->sensitivity = priv->max_sens;
>   
> @@ -395,7 +395,7 @@ static int _rtl92e_wx_set_scan(struct net_device *dev,
>   	rt_state = priv->rtllib->eRFPowerState;
>   	if (!priv->up)
>   		return -ENETDOWN;
> -	if (priv->rtllib->LinkDetectInfo.bBusyTraffic == true)
> +	if (priv->rtllib->LinkDetectInfo.bBusyTraffic)
OK
>   		return -EAGAIN;
>   
>   	if (wrqu->data.flags & IW_SCAN_THIS_ESSID) {
> @@ -582,9 +582,9 @@ static int _rtl92e_wx_set_frag(struct net_device *dev,
>   	if (priv->hw_radio_off)
>   		return 0;
>   
> -	if (wrqu->frag.disabled)
> +	if (wrqu->frag.disabled) {
It is questionable if this is really required.
>   		priv->rtllib->fts = DEFAULT_FRAG_THRESHOLD;
> -	else {
> +	} else {
>   		if (wrqu->frag.value < MIN_FRAG_THRESHOLD ||
>   		    wrqu->frag.value > MAX_FRAG_THRESHOLD)
>   			return -EINVAL;
> @@ -821,7 +821,7 @@ static int _rtl92e_wx_get_sens(struct net_device *dev,
>   {
>   	struct r8192_priv *priv = rtllib_priv(dev);
>   
> -	if (priv->rf_set_sens == NULL)
> +	if (!priv->rf_set_sens)
OK
>   		return -1; /* we have not this support for this radio */
>   	wrqu->sens.value = priv->sens;
>   	return 0;
> @@ -839,7 +839,7 @@ static int _rtl92e_wx_set_sens(struct net_device *dev,
>   		return 0;
>   
>   	mutex_lock(&priv->wx_mutex);
> -	if (priv->rf_set_sens == NULL) {
> +	if (!priv->rf_set_sens) {
OK
>   		err = -1; /* we have not this support for this radio */
>   		goto exit;
>   	}
> @@ -882,7 +882,7 @@ static int _rtl92e_wx_set_encode_ext(struct net_device *dev,
>   		u8 idx = 0, alg = 0, group = 0;
>   
>   		if ((encoding->flags & IW_ENCODE_DISABLED) ||
> -		     ext->alg == IW_ENCODE_ALG_NONE) {
> +		    ext->alg == IW_ENCODE_ALG_NONE) {
This is about indentation and does not really have something to do with if.
>   			ieee->pairwise_key_type = ieee->group_key_type
>   						= KEY_TYPE_NA;
>   			rtl92e_cam_reset(dev);
> @@ -919,7 +919,7 @@ static int _rtl92e_wx_set_encode_ext(struct net_device *dev,
>   					 key, 0);
>   		} else {
>   			if ((ieee->pairwise_key_type == KEY_TYPE_CCMP) &&
> -			     ieee->pHTInfo->bCurrentHTSupport)
> +			    ieee->pHTInfo->bCurrentHTSupport)
This is about indentation and does not really have something to do with if.
>   				rtl92e_writeb(dev, 0x173, 1);
>   			rtl92e_set_key(dev, 4, idx, alg,
>   				       (u8 *)ieee->ap_mac_addr, 0, key);
> @@ -993,7 +993,7 @@ static int _rtl92e_wx_get_gen_ie(struct net_device *dev,
>   	struct r8192_priv *priv = rtllib_priv(dev);
>   	struct rtllib_device *ieee = priv->rtllib;
>   
> -	if (ieee->wpa_ie_len == 0 || ieee->wpa_ie == NULL) {
> +	if (ieee->wpa_ie_len == 0 || !ieee->wpa_ie) {
OK
>   		data->data.length = 0;
>   		return 0;
>   	}

A simple connection test works. But it does not cover all paths that are 
possible under the ifs.

This patch cannot be applied on top of my 10 series patch send earlier. 
Sorry for that.

Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com>







^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-09-25 20:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-25 12:50 [PATCH] staging: rtl8192e: cleanup if statements Valentin Vidic
2022-09-25 20:47 ` Philipp Hortmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).