Skip to contentSkip to conversation

Staging: rtl8188eu: Refine if condition

PATCH In review Vatika Harlalka 3 participants 3 messages Feb 27, 2015 – Mar 2, 2015 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: rtl8188eu: Refine if condition

Variable bound takes maximum value 8 so the if condition for odd i is made more compact.

---
 drivers/staging/rtl8188eu/hal/phy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8188eu/hal/phy.c +1 -1
index 6af72a4..3d0e447 100644
@@ -1038,7 +1038,7 @@ static bool simularity_compare(struct adapter *adapt, s32 resulta[][8],
 		bound = 4;
 
 	for (i = 0; i < bound; i++) {
-		if ((i == 1) || (i == 3) || (i == 5) || (i == 7)) {
+		if (i%2 == 1) {
 			if ((resulta[c1][i] & 0x00000200) != 0)
 				tmp1 = resulta[c1][i] | 0xFFFFFC00;
 			else
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 13 lines · Vatika Harlalka

Variable bound takes maximum value 8 so the if condition for odd i is made more compact.

---
 drivers/staging/rtl8188eu/hal/phy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8188eu/hal/phy.c +0 -0
index 6af72a4..3d0e447 100644

drivers/staging/rtl8188eu/hal/phy.c static bool simularity_compare(struct adapter *adapt, s32 resulta[][8], · line 1041

Quoted 5 lines
drivers/staging/rtl8188eu/hal/phy.c +1 -1
@@ -1038,7 +1038,7 @@ static bool simularity_compare(struct adapter *adapt, s32 resulta[][8],
 		bound = 4;
 
 	for (i = 0; i < bound; i++) {
-		if ((i == 1) || (i == 3) || (i == 5) || (i == 7)) {
+		if (i%2 == 1) {

I find this harder to read now, sorry, '%' is not used often in C code for a reason :)

thanks,

greg k-h

#2 lore raw
Quoted 16 lines · Greg KH
Quoted 15 lines · Vatika Harlalka

Variable bound takes maximum value 8 so the if condition for odd i is made more compact.

---
 drivers/staging/rtl8188eu/hal/phy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8188eu/hal/phy.c +0 -0
index 6af72a4..3d0e447 100644
@@ -1038,7 +1038,7 @@ static bool simularity_compare(struct adapter *adapt, s32 resulta[][8],
 		bound = 4;
 
Quoted 6 lines

drivers/staging/rtl8188eu/hal/phy.c static bool simularity_compare(struct adapter *adapt, s32 resulta[][8], · line 1041

Quoted 3 lines
drivers/staging/rtl8188eu/hal/phy.c +1 -1
 	for (i = 0; i < bound; i++) {
-		if ((i == 1) || (i == 3) || (i == 5) || (i == 7)) {
+		if (i%2 == 1) {

I find this harder to read now, sorry, '%' is not used often in C code for a reason :)

In this case, it is probably more common in the kernel to use

	if ((i & 1) == 1)

in this case.

Jes