staging: rtl8712: Invert the test on check_fwstate() to reduce indentation
authorNarcisa Ana Maria Vasile <narcisaanamaria12@gmail.com>
Tue, 21 Mar 2017 22:52:59 +0000 (00:52 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 23 Mar 2017 13:24:45 +0000 (14:24 +0100)
Negate if condition to be able to return immediately in case of error,
and then continue with the rest of the function
without extra indentation level.

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>
drivers/staging/rtl8712/rtl871x_ioctl_linux.c

index 60c97f764a492f661eaf1729d78c91478fc94475..38c17030eff0088ad988f76cf098c0fe929897dc 100644 (file)
@@ -695,14 +695,14 @@ static int r8711_wx_get_freq(struct net_device *dev,
        struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
        struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;
 
-       if (check_fwstate(pmlmepriv, _FW_LINKED)) {
-               wrqu->freq.m = ieee80211_wlan_frequencies[
-                              pcur_bss->Configuration.DSConfig - 1] * 100000;
-               wrqu->freq.e = 1;
-               wrqu->freq.i = pcur_bss->Configuration.DSConfig;
-       } else {
+       if (!check_fwstate(pmlmepriv, _FW_LINKED))
                return -ENOLINK;
-       }
+
+       wrqu->freq.m = ieee80211_wlan_frequencies[
+                      pcur_bss->Configuration.DSConfig - 1] * 100000;
+       wrqu->freq.e = 1;
+       wrqu->freq.i = pcur_bss->Configuration.DSConfig;
+
        return 0;
 }