Skip to contentSkip to conversation

Staging: rtl8712: Remove zero-testing pointer typed value

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

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: rtl8712: Remove 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/rtl871x_security.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rtl8712/rtl871x_security.c +2 -2
index a178c23..654435f 100644
@@ -153,7 +153,7 @@ static u32 getcrc32(u8 *buf, u32 len)
 	u8 *p;
 	u32  crc;
 
-	if (bcrc32initialized == 0)
+	if (!bcrc32initialized)
 		crc32_init();
 	crc = 0xffffffff; /* preload shift register, per CRC-32 spec */
 	for (p = buf; len > 0; ++p, --len)
@@ -882,7 +882,7 @@ static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext)
 	for (i = 0; i < 16; i++)
 		round_key[i] = key[i];
 	for (round = 0; round < 11; round++) {
-		if (round == 0) {
+		if (!round) {
 			xor_128(round_key, data, ciphertext);
 			next_key(round_key, round);
 		} else if (round == 10) {
Signature · 1 line
1.9.1
#1 lore raw
Quoted 66 lines · Amitoj Kaur Chawla

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/rtl871x_security.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rtl8712/rtl871x_security.c +1 -1
index a178c23..654435f 100644
@@ -153,7 +153,7 @@ static u32 getcrc32(u8 *buf, u32 len)
 	u8 *p;
 	u32  crc;
 
-	if (bcrc32initialized == 0)
+	if (!bcrc32initialized)
 		crc32_init();
 	crc = 0xffffffff; /* preload shift register, per CRC-32 spec */
 	for (p = buf; len > 0; ++p, --len)

drivers/staging/rtl8712/rtl871x_security.c static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext) · line 885

Quoted 5 lines
drivers/staging/rtl8712/rtl871x_security.c +1 -1
@@ -882,7 +882,7 @@ static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext)
 	for (i = 0; i < 16; i++)
 		round_key[i] = key[i];
 	for (round = 0; round < 11; round++) {
-		if (round == 0) {
+		if (!round) {

I'm not sure that it is a good idea in this case. round is 0, 1, 2, etc. It makes sense to test for the value being 0, just like it is later tested for being 10.

julia

Quoted 13 lines
drivers/staging/rtl8712/rtl871x_security.c +0 -0
 			xor_128(round_key, data, ciphertext);
 			next_key(round_key, round);
 		} else if (round == 10) {
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/20150331190408.GA30198%40amitoj-Inspiron-3542.
For more options, visit https://groups.google.com/d/optout.