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 – Apr 1, 2015 Staging

lore
Share & tools
lore
#0 lore raw

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

Removes variable comparison with 0 by using if statement. 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/rtl871x_mp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rtl8712/rtl871x_mp.c +2 -2
index 26201ea..bae3209 100644
@@ -144,7 +144,7 @@ u32 r8712_bb_reg_read(struct _adapter *pAdapter, u16 offset)
 	iocmd.value	= bb_addr;
 	iocmd.index	= IOCMD_BB_READ_IDX;
 	bb_val = fw_iocmd_read(pAdapter, iocmd);
-	if (shift != 0) {
+	if (shift) {
 		u32 bb_val2 = 0;
 
 		bb_val >>= (shift * 8);
@@ -166,7 +166,7 @@ u8 r8712_bb_reg_write(struct _adapter *pAdapter, u16 offset, u32 value)
 	iocmd.cmdclass	= IOCMD_CLASS_BB_RF;
 	iocmd.value	= bb_addr;
 	iocmd.index	= IOCMD_BB_WRITE_IDX;
-	if (shift != 0) {
+	if (shift) {
 		u32 oldValue = 0;
 		u32 newValue = value;
 
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 48 lines · Amitoj Kaur Chawla

Removes variable comparison with 0 by using if statement. 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
)

Quoted 4 lines
---
 drivers/staging/rtl8712/rtl871x_mp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

I don't see a patch 1/2 anywhere :(

Confused. Please resend properly.

greg k-h