* [PATCH] Staging: ks7010: ks_*: Braces should be used on all arms of these statements
@ 2017-02-17 21:41 Shiva Kerdel
2017-02-17 22:50 ` Joe Perches
0 siblings, 1 reply; 3+ messages in thread
From: Shiva Kerdel @ 2017-02-17 21:41 UTC (permalink / raw)
To: gregkh
Cc: wsa+renesas, p.hoefflin, karniksayli1995, sabitha.george,
georgiana.chelu93, goudapatilk, mihaela.muraru21, devel,
linux-kernel, Shiva Kerdel
Braces should be used on all arms of these statements (CHECK)..
Signed-off-by: Shiva Kerdel <shiva@exdev.nl>
---
drivers/staging/ks7010/ks_hostif.c | 6 ++++--
drivers/staging/ks7010/ks_wlan_net.c | 42 +++++++++++++++++++++++-------------
2 files changed, 31 insertions(+), 17 deletions(-)
diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
index 97d7b56c592a..fad1cf5361b0 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -2148,8 +2148,9 @@ void hostif_sme_mode_setup(struct ks_wlan_private *priv)
else
rate_octet[i] =
priv->reg.rate_set.body[i];
- } else
+ } else {
break;
+ }
}
} else { /* D_11G_ONLY_MODE or D_11BG_COMPATIBLE_MODE */
@@ -2163,8 +2164,9 @@ void hostif_sme_mode_setup(struct ks_wlan_private *priv)
else
rate_octet[i] =
priv->reg.rate_set.body[i];
- } else
+ } else {
break;
+ }
}
}
rate_size = i;
diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c
index 121e1530fdba..9cec19f1babc 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -225,9 +225,9 @@ static int ks_wlan_set_freq(struct net_device *dev,
fwrq->m = c + 1;
}
/* Setting by channel number */
- if ((fwrq->m > 1000) || (fwrq->e > 0))
+ if ((fwrq->m > 1000) || (fwrq->e > 0)) {
rc = -EOPNOTSUPP;
- else {
+ } else {
int channel = fwrq->m;
/* We should do a better check than that,
* based on the card capability !!! */
@@ -977,8 +977,9 @@ static int ks_wlan_set_encode(struct net_device *dev,
if (priv->reg.wep_key[index].size) {
priv->reg.wep_index = index;
priv->need_commit |= SME_WEP_INDEX;
- } else
+ } else {
return -EINVAL;
+ }
}
}
}
@@ -1054,8 +1055,9 @@ static int ks_wlan_get_encode(struct net_device *dev,
if ((index >= 0) && (index < 4))
memcpy(extra, priv->reg.wep_key[index].val,
dwrq->length);
- } else
+ } else {
memcpy(extra, zeros, dwrq->length);
+ }
#endif
return 0;
}
@@ -1272,8 +1274,9 @@ static int ks_wlan_set_power(struct net_device *dev,
priv->reg.powermgt = POWMGT_SAVE2_MODE;
else
return -EINVAL;
- } else
+ } else {
return -EINVAL;
+ }
hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST);
@@ -1942,8 +1945,9 @@ static int ks_wlan_set_encode_ext(struct net_device *dev,
return -EINVAL;
}
priv->wpa.key[index].alg = enc->alg;
- } else
+ } else {
return -EINVAL;
+ }
if (commit) {
if (commit & SME_WEP_INDEX)
@@ -2201,8 +2205,9 @@ static int ks_wlan_set_detach(struct net_device *dev,
} else if (*uwrq == DISCONNECT_STATUS) { /* 1 */
priv->connect_status |= FORCE_DISCONNECT;
netif_carrier_off(dev);
- } else
+ } else {
return -EINVAL;
+ }
return 0;
}
@@ -2256,8 +2261,9 @@ static int ks_wlan_set_preamble(struct net_device *dev,
priv->reg.preamble = LONG_PREAMBLE;
} else if (*uwrq == SHORT_PREAMBLE) { /* 1 */
priv->reg.preamble = SHORT_PREAMBLE;
- } else
+ } else {
return -EINVAL;
+ }
priv->need_commit |= SME_MODE_SET;
return -EINPROGRESS; /* Call commit handler */
@@ -2305,8 +2311,9 @@ static int ks_wlan_set_powermgt(struct net_device *dev,
priv->reg.powermgt = POWMGT_SAVE2_MODE;
else
return -EINVAL;
- } else
+ } else {
return -EINVAL;
+ }
hostif_sme_enqueue(priv, SME_POW_MNGMT_REQUEST);
@@ -2346,8 +2353,9 @@ static int ks_wlan_set_scan_type(struct net_device *dev,
priv->reg.scan_type = ACTIVE_SCAN;
} else if (*uwrq == PASSIVE_SCAN) { /* 1 */
priv->reg.scan_type = PASSIVE_SCAN;
- } else
+ } else {
return -EINVAL;
+ }
return 0;
}
@@ -2519,8 +2527,9 @@ static int ks_wlan_set_beacon_lost(struct net_device *dev,
if (priv->reg.operation_mode == MODE_INFRASTRUCTURE) {
priv->need_commit |= SME_MODE_SET;
return -EINPROGRESS; /* Call commit handler */
- } else
+ } else {
return 0;
+ }
}
/*------------------------------------------------------------------*/
@@ -2557,8 +2566,9 @@ static int ks_wlan_set_phy_type(struct net_device *dev,
priv->reg.phy_type = D_11G_ONLY_MODE;
} else if (*uwrq == D_11BG_COMPATIBLE_MODE) { /* 2 */
priv->reg.phy_type = D_11BG_COMPATIBLE_MODE;
- } else
+ } else {
return -EINVAL;
+ }
priv->need_commit |= SME_MODE_SET;
return -EINPROGRESS; /* Call commit handler */
@@ -2596,12 +2606,14 @@ static int ks_wlan_set_cts_mode(struct net_device *dev,
priv->reg.cts_mode = CTS_MODE_FALSE;
} else if (*uwrq == CTS_MODE_TRUE) { /* 1 */
if (priv->reg.phy_type == D_11G_ONLY_MODE ||
- priv->reg.phy_type == D_11BG_COMPATIBLE_MODE)
+ priv->reg.phy_type == D_11BG_COMPATIBLE_MODE) {
priv->reg.cts_mode = CTS_MODE_TRUE;
- else
+ } else {
priv->reg.cts_mode = CTS_MODE_FALSE;
- } else
+ }
+ } else {
return -EINVAL;
+ }
priv->need_commit |= SME_MODE_SET;
return -EINPROGRESS; /* Call commit handler */
--
2.11.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Staging: ks7010: ks_*: Braces should be used on all arms of these statements
2017-02-17 21:41 [PATCH] Staging: ks7010: ks_*: Braces should be used on all arms of these statements Shiva Kerdel
@ 2017-02-17 22:50 ` Joe Perches
2017-02-18 2:37 ` Joe Perches
0 siblings, 1 reply; 3+ messages in thread
From: Joe Perches @ 2017-02-17 22:50 UTC (permalink / raw)
To: Shiva Kerdel, gregkh
Cc: wsa+renesas, p.hoefflin, karniksayli1995, sabitha.george,
georgiana.chelu93, goudapatilk, mihaela.muraru21, devel,
linux-kernel
On Fri, 2017-02-17 at 22:41 +0100, Shiva Kerdel wrote:
> Braces should be used on all arms of these statements (CHECK)..
[]
> diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
[]
> @@ -2148,8 +2148,9 @@ void hostif_sme_mode_setup(struct ks_wlan_private *priv)
> else
> rate_octet[i] =
> priv->reg.rate_set.body[i];
> - } else
> + } else {
> break;
> + }
Generally, any time you see a form like this,
the test should be reversed
for/while/do {
if (foo) {
[bar...]
} else {
break;
}
should be:
for/while/do {
if (!foo)
break;
[bar...]
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Staging: ks7010: ks_*: Braces should be used on all arms of these statements
2017-02-17 22:50 ` Joe Perches
@ 2017-02-18 2:37 ` Joe Perches
0 siblings, 0 replies; 3+ messages in thread
From: Joe Perches @ 2017-02-18 2:37 UTC (permalink / raw)
To: Shiva Kerdel, gregkh
Cc: wsa+renesas, p.hoefflin, karniksayli1995, sabitha.george,
georgiana.chelu93, goudapatilk, mihaela.muraru21, devel,
linux-kernel
On Fri, 2017-02-17 at 14:50 -0800, Joe Perches wrote:
> On Fri, 2017-02-17 at 22:41 +0100, Shiva Kerdel wrote:
> > Braces should be used on all arms of these statements (CHECK)..
>
> []
> > diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c
>
> []
> > @@ -2148,8 +2148,9 @@ void hostif_sme_mode_setup(struct ks_wlan_private *priv)
> > else
> > rate_octet[i] =
> > priv->reg.rate_set.body[i];
> > - } else
> > + } else {
> > break;
> > + }
>
> Generally, any time you see a form like this,
> the test should be reversed
>
> for/while/do {
> if (foo) {
> [bar...]
> } else {
> break;
> }
>
> should be:
>
> for/while/do {
> if (!foo)
> break;
> [bar...]
> }
btw: the code would read better using
a temporary. Something like:
if (priv->reg.phy_type == D_11B_ONLY_MODE) {
for (i = 0; i < priv->reg.rate_set.size; i++) {
u8 rate = priv->reg.rate_set.body[i];
if (!IS_11B_RATE(rate))
break;
rate_octet[i] = ((rate & RATE_MASK) >= TX_RATE_5M)
? (rate & RATE_MASK) : rate;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-02-18 2:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-17 21:41 [PATCH] Staging: ks7010: ks_*: Braces should be used on all arms of these statements Shiva Kerdel
2017-02-17 22:50 ` Joe Perches
2017-02-18 2:37 ` Joe Perches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox