Skip to contentSkip to conversation

Remove Explicit NULL Comparison

PATCH In review Amitoj Kaur Chawla 2 participants 7 messages Oct 7, 2015 – Oct 9, 2015 Staging

lore
Share & tools
lore
#0 lore raw

cover Remove Explicit NULL Comparison

This patchset removes null comparison by using '!' operator. Problems found using checkpatch.pl

Amitoj Kaur Chawla (2):
staging: rtl8712: Remove NULL comparison
staging: rtl8712: Remove NULL comparison

 drivers/staging/rtl8712/hal_init.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/2 staging: rtl8712: Remove NULL comparison

Remove NULL comparison by using '!' operator. Problem found using checkpatch.pl
CHECK: Comparison to NULL could be written "!ptmpchar"

---
 drivers/staging/rtl8712/hal_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8712/hal_init.c +1 -1
index 897dc77..957f033 100644
@@ -178,7 +178,7 @@ static u8 rtl8712_dl_fw(struct _adapter *padapter)
 			  fwhdr.img_IMEM_size : fwhdr.img_SRAM_size;
 		maxlen += txdscp_sz;
 		ptmpchar = kmalloc(maxlen + FWBUFF_ALIGN_SZ, GFP_ATOMIC);
-		if (ptmpchar == NULL)
+		if (!ptmpchar)
 			return ret;
 
 		ptx_desc = (struct tx_desc *)(ptmpchar + FWBUFF_ALIGN_SZ -
Signature · 1 line
1.9.1
#2 lore raw

PATCH 2/2 staging: rtl8712: Remove NULL comparison

In reply to Amitoj Kaur Chawla

Remove NULL comparison by using '!' operator. Problem found using checkpatch.pl
CHECK: Comparison to NULL could be written "!padapter->halpriv.hal_bus_init"

---
 drivers/staging/rtl8712/hal_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8712/hal_init.c +1 -1
index 957f033..081f361 100644
@@ -382,7 +382,7 @@ uint rtl8712_hal_deinit(struct _adapter *padapter)
 uint rtl871x_hal_init(struct _adapter *padapter)
 {
 	padapter->hw_init_completed = false;
-	if (padapter->halpriv.hal_bus_init == NULL)
+	if (!padapter->halpriv.hal_bus_init)
 		return _FAIL;
 	if (padapter->halpriv.hal_bus_init(padapter) != _SUCCESS)
 		return _FAIL;
Signature · 1 line
1.9.1
#3 lore raw

Re: [Outreachy kernel] [PATCH 2/2] staging: rtl8712: Remove NULL comparison

Quoted 14 lines · Amitoj Kaur Chawla

Remove NULL comparison by using '!' operator. Problem found using checkpatch.pl
CHECK: Comparison to NULL could be written "!padapter->halpriv.hal_bus_init"

---
 drivers/staging/rtl8712/hal_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8712/hal_init.c +0 -0
index 957f033..081f361 100644

drivers/staging/rtl8712/hal_init.c uint rtl8712_hal_deinit(struct _adapter *padapter) · line 388

Quoted 8 lines
drivers/staging/rtl8712/hal_init.c +1 -1
@@ -382,7 +382,7 @@ uint rtl8712_hal_deinit(struct _adapter *padapter)
 uint rtl871x_hal_init(struct _adapter *padapter)
 {
 	padapter->hw_init_completed = false;
-	if (padapter->halpriv.hal_bus_init == NULL)
+	if (!padapter->halpriv.hal_bus_init)
 		return _FAIL;
 	if (padapter->halpriv.hal_bus_init(padapter) != _SUCCESS)
 		return _FAIL;

Nothing to do with the patch, but _FAIL and _SUCCESS don't look like standard kernel return values. Maybe it is possible to improve this.

julia

Quoted 10 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/e9962700480ca8590bb9386ab0217b449fc4b8db.1444194896.git.amitoj1606%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

#4 lore raw

Re: [Outreachy kernel] [PATCH 2/2] staging: rtl8712: Remove NULL comparison

Quoted 11 lines · Julia Lawall
Quoted 9 lines · Amitoj Kaur Chawla

Remove NULL comparison by using '!' operator. Problem found using checkpatch.pl
CHECK: Comparison to NULL could be written "!padapter->halpriv.hal_bus_init"

---
 drivers/staging/rtl8712/hal_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 17 lines

drivers/staging/rtl8712/hal_init.c uint rtl8712_hal_deinit(struct _adapter *padapter) · line 388

Quoted 13 lines
drivers/staging/rtl8712/hal_init.c +1 -1
index 957f033..081f361 100644
@@ -382,7 +382,7 @@ uint rtl8712_hal_deinit(struct _adapter *padapter)
 uint rtl871x_hal_init(struct _adapter *padapter)
 {
      padapter->hw_init_completed = false;
-     if (padapter->halpriv.hal_bus_init == NULL)
+     if (!padapter->halpriv.hal_bus_init)
              return _FAIL;
      if (padapter->halpriv.hal_bus_init(padapter) != _SUCCESS)
              return _FAIL;

Nothing to do with the patch, but _FAIL and _SUCCESS don't look like standard kernel return values. Maybe it is possible to improve this.

I've been checking about this but _FAIL and _SUCCESS are used in a lot of places as return values.
What do you suggest?

Signature · 1 line
Amitoj
#5 lore raw

Re: [Outreachy kernel] [PATCH 2/2] staging: rtl8712: Remove NULL comparison

Quoted 29 lines · Amitoj Kaur Chawla
Quoted 11 lines · Julia Lawall
Quoted 9 lines · Amitoj Kaur Chawla

Remove NULL comparison by using '!' operator. Problem found using checkpatch.pl
CHECK: Comparison to NULL could be written "!padapter->halpriv.hal_bus_init"

---
 drivers/staging/rtl8712/hal_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 17 lines

drivers/staging/rtl8712/hal_init.c uint rtl8712_hal_deinit(struct _adapter *padapter) · line 388

Quoted 13 lines
drivers/staging/rtl8712/hal_init.c +1 -1
index 957f033..081f361 100644
@@ -382,7 +382,7 @@ uint rtl8712_hal_deinit(struct _adapter *padapter)
 uint rtl871x_hal_init(struct _adapter *padapter)
 {
      padapter->hw_init_completed = false;
-     if (padapter->halpriv.hal_bus_init == NULL)
+     if (!padapter->halpriv.hal_bus_init)
              return _FAIL;
      if (padapter->halpriv.hal_bus_init(padapter) != _SUCCESS)
              return _FAIL;

Nothing to do with the patch, but _FAIL and _SUCCESS don't look like standard kernel return values. Maybe it is possible to improve this.

Quoted 3 lines

I've been checking about this but _FAIL and _SUCCESS are used in a lot of places as return values.
What do you suggest?

_FAIL is 0 and _SUCCESS is 1. In most of the kernel, failure is indicated by a descriptive error code, like -ENOMEM when some kind of memory allocation fails. It's probably not practical to change the whole driver at once. But perhaps you could find some functions that are only called from a few places, and make the change gradually.

julia

#6 lore raw

Re: [Outreachy kernel] [PATCH 2/2] staging: rtl8712: Remove NULL comparison

Quoted 37 lines · Julia Lawall
Quoted 29 lines · Amitoj Kaur Chawla
Quoted 11 lines · Julia Lawall
Quoted 9 lines · Amitoj Kaur Chawla

Remove NULL comparison by using '!' operator. Problem found using checkpatch.pl
CHECK: Comparison to NULL could be written "!padapter->halpriv.hal_bus_init"

---
 drivers/staging/rtl8712/hal_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 17 lines

drivers/staging/rtl8712/hal_init.c uint rtl8712_hal_deinit(struct _adapter *padapter) · line 388

Quoted 13 lines
drivers/staging/rtl8712/hal_init.c +1 -1
index 957f033..081f361 100644
@@ -382,7 +382,7 @@ uint rtl8712_hal_deinit(struct _adapter *padapter)
 uint rtl871x_hal_init(struct _adapter *padapter)
 {
      padapter->hw_init_completed = false;
-     if (padapter->halpriv.hal_bus_init == NULL)
+     if (!padapter->halpriv.hal_bus_init)
              return _FAIL;
      if (padapter->halpriv.hal_bus_init(padapter) != _SUCCESS)
              return _FAIL;

Nothing to do with the patch, but _FAIL and _SUCCESS don't look like standard kernel return values. Maybe it is possible to improve this.

Quoted 3 lines

I've been checking about this but _FAIL and _SUCCESS are used in a lot of places as return values.
What do you suggest?

Quoted 6 lines

_FAIL is 0 and _SUCCESS is 1. In most of the kernel, failure is indicated by a descriptive error code, like -ENOMEM when some kind of memory allocation fails. It's probably not practical to change the whole driver at once. But perhaps you could find some functions that are only called from a few places, and make the change gradually.

Okay, I'll look into this.

Thanks,

Amitoj