Staging: rtl8188eu: Remove redundant local variable
authorSomya Anand <somyaanand214@gmail.com>
Mon, 9 Mar 2015 13:48:24 +0000 (19:18 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 15 Mar 2015 17:41:10 +0000 (18:41 +0100)
This patch removes a redundant variable "val" and adds
inline return statements. It also adds a default case
to the switch statement which returns 0 to keep the logic
intact.

It also removes a redundant variable "inx" and adds inline
return statements.

This issue is identified by the following coccinelle script.
@@
expression ret;
identifier f;
@@

-ret =
+return
     f(...);
-return ret;

Signed-off-by: Somya Anand <somyaanand214@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8188eu/core/rtw_wlan_util.c

index 509fc05ebea867dbc50b076d1f153dd7b80b71e4..9e9645b453f155419a1f724138b98ef00d04aa34 100644 (file)
@@ -136,47 +136,34 @@ u8 judge_network_type(struct adapter *padapter, unsigned char *rate, int ratelen
 
 static unsigned char ratetbl_val_2wifirate(unsigned char rate)
 {
-       unsigned char val = 0;
-
        switch (rate & 0x7f) {
        case 0:
-               val = IEEE80211_CCK_RATE_1MB;
-               break;
+               return IEEE80211_CCK_RATE_1MB;
        case 1:
-               val = IEEE80211_CCK_RATE_2MB;
-               break;
+               return IEEE80211_CCK_RATE_2MB;
        case 2:
-               val = IEEE80211_CCK_RATE_5MB;
-               break;
+               return IEEE80211_CCK_RATE_5MB;
        case 3:
-               val = IEEE80211_CCK_RATE_11MB;
-               break;
+               return IEEE80211_CCK_RATE_11MB;
        case 4:
-               val = IEEE80211_OFDM_RATE_6MB;
-               break;
+               return IEEE80211_OFDM_RATE_6MB;
        case 5:
-               val = IEEE80211_OFDM_RATE_9MB;
-               break;
+               return IEEE80211_OFDM_RATE_9MB;
        case 6:
-               val = IEEE80211_OFDM_RATE_12MB;
-               break;
+               return IEEE80211_OFDM_RATE_12MB;
        case 7:
-               val = IEEE80211_OFDM_RATE_18MB;
-               break;
+               return IEEE80211_OFDM_RATE_18MB;
        case 8:
-               val = IEEE80211_OFDM_RATE_24MB;
-               break;
+               return IEEE80211_OFDM_RATE_24MB;
        case 9:
-               val = IEEE80211_OFDM_RATE_36MB;
-               break;
+               return IEEE80211_OFDM_RATE_36MB;
        case 10:
-               val = IEEE80211_OFDM_RATE_48MB;
-               break;
+               return IEEE80211_OFDM_RATE_48MB;
        case 11:
-               val = IEEE80211_OFDM_RATE_54MB;
-               break;
+               return IEEE80211_OFDM_RATE_54MB;
+       default:
+               return 0;
        }
-       return val;
 }
 
 static int is_basicrate(struct adapter *padapter, unsigned char rate)
@@ -1209,48 +1196,36 @@ unsigned int is_ap_in_wep(struct adapter *padapter)
 
 static int wifirate2_ratetbl_inx(unsigned char rate)
 {
-       int     inx = 0;
        rate = rate & 0x7f;
 
        switch (rate) {
        case 54*2:
-               inx = 11;
-               break;
+               return 11;
        case 48*2:
-               inx = 10;
-               break;
+               return 10;
        case 36*2:
-               inx = 9;
-               break;
+               return 9;
        case 24*2:
-               inx = 8;
-               break;
+               return 8;
        case 18*2:
-               inx = 7;
-               break;
+               return 7;
        case 12*2:
-               inx = 6;
-               break;
+               return 6;
        case 9*2:
-               inx = 5;
-               break;
+               return 5;
        case 6*2:
-               inx = 4;
-               break;
+               return 4;
        case 11*2:
-               inx = 3;
-               break;
+               return 3;
        case 11:
-               inx = 2;
-               break;
+               return 2;
        case 2*2:
-               inx = 1;
-               break;
+               return 1;
        case 1*2:
-               inx = 0;
-               break;
+               return 0;
+       default:
+               return 0;
        }
-       return inx;
 }
 
 unsigned int update_basic_rate(unsigned char *ptn, unsigned int ptn_sz)