summaryrefslogtreecommitdiff
path: root/drivers/staging/rtl8712
diff options
context:
space:
mode:
authorNarcisa Ana Maria Vasile <narcisaanamaria12@gmail.com>2017-03-22 01:52:40 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-03-23 16:24:45 +0300
commite6d9379507d77c08fb9f91c8430c3f87ceb38d29 (patch)
treee9be9bb4c1c32f7c121f5fa2a84906e007739bde /drivers/staging/rtl8712
parentff49304b5b7b0136eb2954163dfa7c0739312169 (diff)
downloadlinux-e6d9379507d77c08fb9f91c8430c3f87ceb38d29.tar.xz
staging: rtl8712: Invert if statements to reduce indentation level
Invert if statements to be able to return immediately in case of error, and to avoid additional else branch, and then continue with the rest of the function without excessive indentation. This was found using the following Coccinelle script: @disable neg_if@ expression e,E; statement S; @@ *if (e) S else { return -E; } @disable neg_if@ expression e,E; statement S; identifier l; @@ *if (e) S else { rc = -E; goto l; } Signed-off-by: Narcisa Ana Maria Vasile <narcisaanamaria12@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/rtl8712')
-rw-r--r--drivers/staging/rtl8712/rtl871x_ioctl_linux.c39
1 files changed, 17 insertions, 22 deletions
diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
index 032279526d17..60c97f764a49 100644
--- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
+++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c
@@ -378,13 +378,12 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
if (param_len != (u32)((u8 *) param->u.crypt.key - (u8 *)param) +
param->u.crypt.key_len)
return -EINVAL;
- if (is_broadcast_ether_addr(param->sta_addr)) {
- if (param->u.crypt.idx >= WEP_KEYS) {
- /* for large key indices, set the default (0) */
- param->u.crypt.idx = 0;
- }
- } else {
+ if (!is_broadcast_ether_addr(param->sta_addr))
return -EINVAL;
+
+ if (param->u.crypt.idx >= WEP_KEYS) {
+ /* for large key indices, set the default (0) */
+ param->u.crypt.idx = 0;
}
if (strcmp(param->u.crypt.alg, "WEP") == 0) {
netdev_info(dev, "r8712u: %s: crypt.alg = WEP\n", __func__);
@@ -396,23 +395,19 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param,
wep_key_len = param->u.crypt.key_len;
if (wep_key_idx >= WEP_KEYS)
wep_key_idx = 0;
- if (wep_key_len > 0) {
- wep_key_len = wep_key_len <= 5 ? 5 : 13;
- pwep = kzalloc(sizeof(*pwep), GFP_ATOMIC);
- if (!pwep)
- return -ENOMEM;
- pwep->KeyLength = wep_key_len;
- pwep->Length = wep_key_len +
- FIELD_OFFSET(struct NDIS_802_11_WEP,
- KeyMaterial);
- if (wep_key_len == 13) {
- padapter->securitypriv.PrivacyAlgrthm =
- _WEP104_;
- padapter->securitypriv.XGrpPrivacy =
- _WEP104_;
- }
- } else {
+ if (wep_key_len <= 0)
return -EINVAL;
+
+ wep_key_len = wep_key_len <= 5 ? 5 : 13;
+ pwep = kzalloc(sizeof(*pwep), GFP_ATOMIC);
+ if (!pwep)
+ return -ENOMEM;
+ pwep->KeyLength = wep_key_len;
+ pwep->Length = wep_key_len +
+ FIELD_OFFSET(struct NDIS_802_11_WEP, KeyMaterial);
+ if (wep_key_len == 13) {
+ padapter->securitypriv.PrivacyAlgrthm = _WEP104_;
+ padapter->securitypriv.XGrpPrivacy = _WEP104_;
}
pwep->KeyIndex = wep_key_idx;
pwep->KeyIndex |= 0x80000000;