If statement conditional chains multiple logical AND's and OR's together making the code overly complex to read. The same condition appears in each and every OR'ed statement. This logic can be more easily represented by simply checking the value of this condition initially and returning if it evaluates to false. Declare variable 'do_mic', assign truth value to 'do_mic' as it appears in original conditional statement. AND in the key length, as in original. If variable 'do_mic' is false, return from function. Do not change program logic. Signed-off-by: Tobin C. Harding <me@xxxxxxxx> --- drivers/staging/ks7010/ks_hostif.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c index e17ce22..d9f3a0d 100644 --- a/drivers/staging/ks7010/ks_hostif.c +++ b/drivers/staging/ks7010/ks_hostif.c @@ -320,6 +320,7 @@ int hostif_data_indication_wpa(struct ks_wlan_private *priv, union iwreq_data wrqu; unsigned int key_index = auth_type - 1; struct wpa_key_t *key = &priv->wpa.key[key_index]; + int do_mic; eth_hdr = (struct ether_hdr *)(priv->rxp); eth_proto = ntohs(eth_hdr->h_proto); @@ -333,13 +334,14 @@ int hostif_data_indication_wpa(struct ks_wlan_private *priv, priv->nstats.rx_errors++; return -EINVAL; } - 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)) && - key->key_len) { + + do_mic = priv->wpa.pairwise_suite == IW_AUTH_CIPHER_TKIP && key->key_len; + if (!do_mic) + return 0; + + if (auth_type == TYPE_PMK1 || + auth_type == TYPE_GMK1 || + auth_type == TYPE_GMK2) { DPRINTK(4, "TKIP: protocol=%04X: size=%u\n", eth_proto, priv->rx_size); /* MIC save */ -- 2.7.4 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel