Skip to contentSkip to conversation

Staging: rtl8712: Fix zero-testing pointer typed value

PATCH In review Amitoj Kaur Chawla 2 participants 2 messages Mar 31, 2015 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Staging: rtl8712: Fix zero-testing pointer typed value

Removes variable comparison with 0 by using !. Done using following coccinelle script.

@ disable is_zero,isnt_zero @
expression *E;
expression E1,f;
@@

E = f(...)
<...
(
- E == 0
+ !E
|
- E != 0
+ E
|
- 0 == E
+ !E
|
- 0 != E
+ E
)
...>
?E = E1

@ disable is_zero,isnt_zero @
expression *E;
@@

(
E ==
- 0
+ NULL
|
E !=
- 0
+ NULL
|
- 0
+ NULL
== E
|
- 0
+ NULL
!= E
)

---
 drivers/staging/rtl8712/rtl8712_cmd.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/staging/rtl8712/rtl8712_cmd.c +5 -5
index 007f0a3..26971b5 100644
@@ -91,7 +91,7 @@ static void query_fw_rx_phy_status(struct _adapter *padapter)
 			pollingcnts--;
 			msleep(20);
 		}
-		if (pollingcnts != 0)
+		if (pollingcnts)
 			val32 = r8712_read32(padapter, IOCMD_DATA_REG);
 		else /* time out */
 			val32 = 0;
@@ -289,12 +289,12 @@ u8 r8712_fw_cmd(struct _adapter *pAdapter, u32 cmd)
 
 	r8712_write32(pAdapter, IOCMD_CTRL_REG, cmd);
 	msleep(100);
-	while ((0 != r8712_read32(pAdapter, IOCMD_CTRL_REG)) &&
+	while ((r8712_read32(pAdapter, IOCMD_CTRL_REG)) &&
 	       (pollingcnts > 0)) {
 		pollingcnts--;
 		msleep(20);
 	}
-	if (pollingcnts == 0)
+	if (!pollingcnts)
 		return false;
 	return true;
 }
@@ -346,10 +346,10 @@ _next:
 			pdesc->txdw0 |= cpu_to_le32((wr_sz-TXDESC_SIZE) &
 						     0x0000ffff);
 			if (pdvobj->ishighspeed) {
-				if ((wr_sz % 512) == 0)
+				if (!wr_sz % 512)
 					blnPending = 1;
 			} else {
-				if ((wr_sz % 64) == 0)
+				if (!wr_sz % 64)
 					blnPending = 1;
 			}
 			if (blnPending) /* 32 bytes for TX Desc - 8 offset */
Signature · 1 line
1.9.1
#1 lore raw

drivers/staging/rtl8712/rtl8712_cmd.c _next: · line 349

Quoted 3 lines
drivers/staging/rtl8712/rtl8712_cmd.c +1 -1
 			if (pdvobj->ishighspeed) {
-				if ((wr_sz % 512) == 0)
+				if (!wr_sz % 512)

This does not look correct. !wr_sz is 1 or 0. Did Coccinelle generate the code for you this way?

julia

Quoted 17 lines
drivers/staging/rtl8712/rtl8712_cmd.c +1 -1
 					blnPending = 1;
 			} else {
-				if ((wr_sz % 64) == 0)
+				if (!wr_sz % 64)
 					blnPending = 1;
 			}
 			if (blnPending) /* 32 bytes for TX Desc - 8 offset */
Signature · 8 lines
1.9.1

-- 
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20150331195003.GA30918%40amitoj-Inspiron-3542.
For more options, visit https://groups.google.com/d/optout.