Skip to contentSkip to conversation

Staging: rtl8712: Remove unnecessary else after return or break

PATCH In review Dilek Uzulmez 2 participants 2 messages Feb 22, 2015 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: rtl8712: Remove unnecessary else after return or break

This patch fixes checkpatch.pl warning in files of rtl8712
WARNING: else is not generally useful after a break or return

---
 drivers/staging/rtl8712/rtl871x_ioctl_linux.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rtl8712/rtl871x_ioctl_linux.c +2 -2
index 9bb364f..3a1b8b2 100644
@@ -612,8 +612,8 @@ static int r871x_set_wpa_ie(struct _adapter *padapter, char *pie,
 					netdev_info(padapter->pnetdev, "r8712u: SET WPS_IE, wps_phase==true\n");
 					cnt += buf[cnt+1]+2;
 					break;
-				} else
-					cnt += buf[cnt + 1] + 2;
+				}
+				cnt += buf[cnt + 1] + 2;
 			}
 		}
 	}
Signature · 1 line
1.9.1
#1 lore raw
Quoted 5 lines · On Sunday 22 February 2015 18:40:18 Dilek Uzulmez wrote:
drivers/staging/rtl8712/rtl871x_ioctl_linux.c +0 -0
index 9bb364f..3a1b8b2 100644

drivers/staging/rtl8712/rtl871x_ioctl_linux.c static int r871x_set_wpa_ie(struct _adapter *padapter, char *pie, · line 619

Quoted 10 lines
drivers/staging/rtl8712/rtl871x_ioctl_linux.c +2 -2
@@ -612,8 +612,8 @@ static int r871x_set_wpa_ie(struct _adapter *padapter, char *pie,
                                        netdev_info(padapter->pnetdev, "r8712u: SET WPS_IE, wps_phase==true\n");
                                        cnt += buf[cnt+1]+2;
                                        break;
-                               } else
-                                       cnt += buf[cnt + 1] + 2;
+                               }
+                               cnt += buf[cnt + 1] + 2;
                        }
                }
        }

The 'else' clause here seems to be much smaller than the 'if' clause.

How about negating the condition to have the shorter path indented and then reformat the other one?

Similarly, you could do the same change to the outer 'if' condition and just return early from the function if 'ielen' is zero to remove one more level of indentation, and you can move the variable declarations to the top of the function to gain yet another level.

Finally, you can add a temporary variable to cache a pointer to padapter->securitypriv that will allow you to avoid most of the line breaks.

After that, the function should become much easier to read, which is what the warning you got is all about. Changing the one line here doesn't seem to be all that helpful if you don't change the other parts at the same time.

Arnd