'if' statement conditional guards large block of code. Conditional can
be inverted and function made to return. This allows following code to
have one level of indentation removed.

Invert conditional and return directly if new conditioal is true.
Remove one level of indentation.

Signed-off-by: Tobin C. Harding <m...@tobin.cc>
---

Correct error constant to return?

 drivers/staging/ks7010/ks_hostif.c | 143 +++++++++++++++++++------------------
 1 file changed, 72 insertions(+), 71 deletions(-)

diff --git a/drivers/staging/ks7010/ks_hostif.c 
b/drivers/staging/ks7010/ks_hostif.c
index 565f051..d28e9af 100644
--- a/drivers/staging/ks7010/ks_hostif.c
+++ b/drivers/staging/ks7010/ks_hostif.c
@@ -414,81 +414,82 @@ static int function_needs_naming(struct ks_wlan_private 
*priv,
        struct mic_failure_t *mic_failure;
        union iwreq_data wrqu;
 
-       if (memcmp(&eth_hdr->h_source[0], &priv->eth_addr[0], ETH_ALEN)) {      
/* source address check */
-               if (eth_hdr->h_dest_snap != eth_hdr->h_source_snap) {
-                       DPRINTK(1, "invalid data format\n");
-                       priv->nstats.rx_errors++;
-                       return -ERROR;
-               }
+       if (memcmp(&eth_hdr->h_source[0], &priv->eth_addr[0], ETH_ALEN) != 0)
+               return 0;
+
+       if (eth_hdr->h_dest_snap != eth_hdr->h_source_snap) {
+               DPRINTK(1, "invalid data format\n");
+               priv->nstats.rx_errors++;
+               return -ERROR;
+       }
+
+       auth_type = get_WORD(priv);     /* AuthType */
+       eth_proto = ntohs(eth_hdr->h_proto);
 
-               auth_type = get_WORD(priv);     /* AuthType */
-               eth_proto = ntohs(eth_hdr->h_proto);
-
-               if (((auth_type == TYPE_PMK1
-                                       && priv->wpa.pairwise_suite ==
-                                       IW_AUTH_CIPHER_TKIP) || (auth_type == 
TYPE_GMK1
-                                                               && priv->wpa.
-                                                               group_suite ==
-                                                               
IW_AUTH_CIPHER_TKIP)
-                               || (auth_type == TYPE_GMK2
-                                       && priv->wpa.group_suite ==
-                                       IW_AUTH_CIPHER_TKIP))
-                       && priv->wpa.key[auth_type - 1].key_len) {
-                       DPRINTK(4, "TKIP: protocol=%04X: size=%u\n",
-                               eth_proto, priv->rx_size);
-                       /* MIC save */
-                       memcpy(&RecvMIC[0],
-                               (priv->rxp) + ((priv->rx_size) - 8), 8);
-                       priv->rx_size = priv->rx_size - 8;
-                       if (auth_type > 0 && auth_type < 4) {   /* auth_type 
check */
-                               MichaelMICFunction(&michel_mic, (uint8_t *) 
priv->wpa.key[auth_type - 1].rx_mic_key, (uint8_t *) priv->rxp, 
(int)priv->rx_size, (uint8_t) 0,    /* priority */
-                                               (uint8_t *)
-                                               michel_mic.Result);
+       if (((auth_type == TYPE_PMK1
+                               && priv->wpa.pairwise_suite ==
+                               IW_AUTH_CIPHER_TKIP) || (auth_type == TYPE_GMK1
+                                                       && priv->wpa.
+                                                       group_suite ==
+                                                       IW_AUTH_CIPHER_TKIP)
+                       || (auth_type == TYPE_GMK2
+                               && priv->wpa.group_suite ==
+                               IW_AUTH_CIPHER_TKIP))
+               && priv->wpa.key[auth_type - 1].key_len) {
+               DPRINTK(4, "TKIP: protocol=%04X: size=%u\n",
+                       eth_proto, priv->rx_size);
+               /* MIC save */
+               memcpy(&RecvMIC[0],
+                       (priv->rxp) + ((priv->rx_size) - 8), 8);
+               priv->rx_size = priv->rx_size - 8;
+               if (auth_type > 0 && auth_type < 4) {   /* auth_type check */
+                       MichaelMICFunction(&michel_mic, (uint8_t *) 
priv->wpa.key[auth_type - 1].rx_mic_key, (uint8_t *) priv->rxp, 
(int)priv->rx_size, (uint8_t) 0,    /* priority */
+                                       (uint8_t *)
+                                       michel_mic.Result);
+               }
+               if (memcmp(michel_mic.Result, RecvMIC, 8)) {
+                       now = jiffies;
+                       mic_failure = &priv->wpa.mic_failure;
+                       /* MIC FAILURE */
+                       if (mic_failure->last_failure_time &&
+                               (now -
+                                       mic_failure->last_failure_time) /
+                               HZ >= 60) {
+                               mic_failure->failure = 0;
                        }
-                       if (memcmp(michel_mic.Result, RecvMIC, 8)) {
-                               now = jiffies;
-                               mic_failure = &priv->wpa.mic_failure;
-                               /* MIC FAILURE */
-                               if (mic_failure->last_failure_time &&
-                                       (now -
-                                               mic_failure->last_failure_time) 
/
-                                       HZ >= 60) {
-                                       mic_failure->failure = 0;
-                               }
-                               DPRINTK(4, "MIC FAILURE\n");
-                               if (mic_failure->failure == 0) {
-                                       mic_failure->failure = 1;
-                                       mic_failure->counter = 0;
-                               } else if (mic_failure->failure == 1) {
-                                       mic_failure->failure = 2;
+                       DPRINTK(4, "MIC FAILURE\n");
+                       if (mic_failure->failure == 0) {
+                               mic_failure->failure = 1;
+                               mic_failure->counter = 0;
+                       } else if (mic_failure->failure == 1) {
+                               mic_failure->failure = 2;
+                               mic_failure->counter =
+                                       (uint16_t) ((now -
+                                                       mic_failure->
+                                                       last_failure_time)
+                                               / HZ);
+                               if (!mic_failure->counter)      /* mic_failure 
counter value range 1-60 */
                                        mic_failure->counter =
-                                               (uint16_t) ((now -
-                                                               mic_failure->
-                                                               
last_failure_time)
-                                                       / HZ);
-                                       if (!mic_failure->counter)      /* 
mic_failure counter value range 1-60 */
-                                               mic_failure->counter =
-                                                       1;
-                               }
-                               priv->wpa.mic_failure.
-                                       last_failure_time = now;
-                               /*  needed parameters: count, keyid, key type, 
TSC */
-                               sprintf(buf,
-                                       
"MLME-MICHAELMICFAILURE.indication(keyid=%d %scast addr="
-                                       "%pM)",
-                                       auth_type - 1,
-                                       eth_hdr->
-                                       h_dest[0] & 0x01 ? "broad" :
-                                       "uni", eth_hdr->h_source);
-                               memset(&wrqu, 0, sizeof(wrqu));
-                               wrqu.data.length = strlen(buf);
-                               DPRINTK(4,
-                                       "IWEVENT:MICHAELMICFAILURE\n");
-                               wireless_send_event(priv->net_dev,
-                                               IWEVCUSTOM, &wrqu,
-                                               buf);
-                               return -ERROR;
+                                               1;
                        }
+                       priv->wpa.mic_failure.
+                               last_failure_time = now;
+                       /*  needed parameters: count, keyid, key type, TSC */
+                       sprintf(buf,
+                               "MLME-MICHAELMICFAILURE.indication(keyid=%d 
%scast addr="
+                               "%pM)",
+                               auth_type - 1,
+                               eth_hdr->
+                               h_dest[0] & 0x01 ? "broad" :
+                               "uni", eth_hdr->h_source);
+                       memset(&wrqu, 0, sizeof(wrqu));
+                       wrqu.data.length = strlen(buf);
+                       DPRINTK(4,
+                               "IWEVENT:MICHAELMICFAILURE\n");
+                       wireless_send_event(priv->net_dev,
+                                       IWEVCUSTOM, &wrqu,
+                                       buf);
+                       return -ERROR;
                }
        }
        return 0;
-- 
2.7.4

_______________________________________________
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to