linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] staging: Clean up tests if NULL returned on failure
@ 2017-03-04 16:46 simran singhal
  2017-03-04 16:46 ` [PATCH 1/3] staging: rtl8192u: " simran singhal
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: simran singhal @ 2017-03-04 16:46 UTC (permalink / raw)
  To: w.d.hubbs
  Cc: chris, gregkh, devel, linux-kernel, speakup, linux-rpi-kernel,
	outreachy-kernel, linux-arm-kernel

This patch series tests if functions like kmalloc/kzalloc return NULL
on failure. When NULL represents failure, !x is commonly used.

simran singhal (3):
  staging: rtl8192u: Clean up tests if NULL returned on failure
  staging: speakup: Clean up tests if NULL returned on failure
  staging: vc04_services: Clean up tests if NULL returned on failure

 drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c      | 2 +-
 drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c       | 2 +-
 drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c         | 2 +-
 drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c              | 4 ++--
 drivers/staging/speakup/main.c                                 | 2 +-
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c | 2 +-
 6 files changed, 7 insertions(+), 7 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] staging: rtl8192u: Clean up tests if NULL returned on failure
  2017-03-04 16:46 [PATCH 0/3] staging: Clean up tests if NULL returned on failure simran singhal
@ 2017-03-04 16:46 ` simran singhal
  2017-03-04 16:46 ` [PATCH 2/3] staging: speakup: " simran singhal
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: simran singhal @ 2017-03-04 16:46 UTC (permalink / raw)
  To: w.d.hubbs
  Cc: chris, gregkh, devel, linux-kernel, speakup, linux-rpi-kernel,
	outreachy-kernel, linux-arm-kernel

Some functions like kmalloc/kzalloc return NULL on failure.
When NULL represents failure, !x is commonly used.

This was done using Coccinelle:
@@
expression *e;
identifier l1;
@@

e = \(kmalloc\|kzalloc\|kcalloc\|devm_kzalloc\)(...);
...
- e == NULL
+ !e

Signed-off-by: simran singhal <singhalsimran0@gmail.com>
---
 drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c | 2 +-
 drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c  | 2 +-
 drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c    | 2 +-
 drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c         | 4 ++--
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c
index 713f1d6..df94021 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c
@@ -67,7 +67,7 @@ static void *ieee80211_tkip_init(int key_idx)
 	struct ieee80211_tkip_data *priv;
 
 	priv = kzalloc(sizeof(*priv), GFP_ATOMIC);
-	if (priv == NULL)
+	if (!priv)
 		goto fail;
 	priv->key_idx = key_idx;
 
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c
index 0e8c876..7ba4b07 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c
@@ -42,7 +42,7 @@ static void *prism2_wep_init(int keyidx)
 	struct prism2_wep_data *priv;
 
 	priv = kzalloc(sizeof(*priv), GFP_ATOMIC);
-	if (priv == NULL)
+	if (!priv)
 		return NULL;
 	priv->key_idx = keyidx;
 
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
index 1bff0e9..4adab30 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
@@ -3025,7 +3025,7 @@ static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee,
 		ieee80211_crypt_delayed_deinit(ieee, crypt);
 
 		new_crypt = kzalloc(sizeof(*new_crypt), GFP_KERNEL);
-		if (new_crypt == NULL) {
+		if (!new_crypt) {
 			ret = -ENOMEM;
 			goto done;
 		}
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
index 2481c21..c925e53 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
@@ -362,7 +362,7 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee,
 		/* take WEP into use */
 		new_crypt = kzalloc(sizeof(struct ieee80211_crypt_data),
 				    GFP_KERNEL);
-		if (new_crypt == NULL)
+		if (!new_crypt)
 			return -ENOMEM;
 		new_crypt->ops = ieee80211_get_crypto_ops("WEP");
 		if (!new_crypt->ops) {
@@ -610,7 +610,7 @@ int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee,
 		ieee80211_crypt_delayed_deinit(ieee, crypt);
 
 		new_crypt = kzalloc(sizeof(*new_crypt), GFP_KERNEL);
-		if (new_crypt == NULL) {
+		if (!new_crypt) {
 			ret = -ENOMEM;
 			goto done;
 		}
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] staging: speakup: Clean up tests if NULL returned on failure
  2017-03-04 16:46 [PATCH 0/3] staging: Clean up tests if NULL returned on failure simran singhal
  2017-03-04 16:46 ` [PATCH 1/3] staging: rtl8192u: " simran singhal
@ 2017-03-04 16:46 ` simran singhal
  2017-03-04 16:46 ` [PATCH 3/3] staging: vc04_services: " simran singhal
  2017-03-04 17:29 ` [Outreachy kernel] [PATCH 0/3] staging: " Julia Lawall
  3 siblings, 0 replies; 5+ messages in thread
From: simran singhal @ 2017-03-04 16:46 UTC (permalink / raw)
  To: w.d.hubbs
  Cc: chris, gregkh, devel, linux-kernel, speakup, linux-rpi-kernel,
	outreachy-kernel, linux-arm-kernel

Some functions like kmalloc/kzalloc return NULL on failure.
When NULL represents failure, !x is commonly used.

This was done using Coccinelle:
@@
expression *e;
identifier l1;
@@

e = \(kmalloc\|kzalloc\|kcalloc\|devm_kzalloc\)(...);
...
- e == NULL
+ !e

Signed-off-by: simran singhal <singhalsimran0@gmail.com>
---
 drivers/staging/speakup/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c
index c2f70ef..e8268bc 100644
--- a/drivers/staging/speakup/main.c
+++ b/drivers/staging/speakup/main.c
@@ -1324,7 +1324,7 @@ static int speakup_allocate(struct vc_data *vc)
 	if (speakup_console[vc_num] == NULL) {
 		speakup_console[vc_num] = kzalloc(sizeof(*speakup_console[0]),
 						  GFP_ATOMIC);
-		if (speakup_console[vc_num] == NULL)
+		if (!speakup_console[vc_num])
 			return -ENOMEM;
 		speakup_date(vc);
 	} else if (!spk_parked)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] staging: vc04_services: Clean up tests if NULL returned on failure
  2017-03-04 16:46 [PATCH 0/3] staging: Clean up tests if NULL returned on failure simran singhal
  2017-03-04 16:46 ` [PATCH 1/3] staging: rtl8192u: " simran singhal
  2017-03-04 16:46 ` [PATCH 2/3] staging: speakup: " simran singhal
@ 2017-03-04 16:46 ` simran singhal
  2017-03-04 17:29 ` [Outreachy kernel] [PATCH 0/3] staging: " Julia Lawall
  3 siblings, 0 replies; 5+ messages in thread
From: simran singhal @ 2017-03-04 16:46 UTC (permalink / raw)
  To: w.d.hubbs
  Cc: chris, gregkh, devel, linux-kernel, speakup, linux-rpi-kernel,
	outreachy-kernel, linux-arm-kernel

Some functions like kmalloc/kzalloc return NULL on failure.
When NULL represents failure, !x is commonly used.

This was done using Coccinelle:
@@
expression *e;
identifier l1;
@@

e = \(kmalloc\|kzalloc\|kcalloc\|devm_kzalloc\)(...);
...
- e == NULL
+ !e

Signed-off-by: simran singhal <singhalsimran0@gmail.com>
---
 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c
index e0ba0ed..7fa0310 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c
@@ -52,7 +52,7 @@ int vchiu_queue_init(VCHIU_QUEUE_T *queue, int size)
 	sema_init(&queue->push, 0);
 
 	queue->storage = kzalloc(size * sizeof(VCHIQ_HEADER_T *), GFP_KERNEL);
-	if (queue->storage == NULL) {
+	if (!queue->storage) {
 		vchiu_queue_delete(queue);
 		return 0;
 	}
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Outreachy kernel] [PATCH 0/3] staging: Clean up tests if NULL returned on failure
  2017-03-04 16:46 [PATCH 0/3] staging: Clean up tests if NULL returned on failure simran singhal
                   ` (2 preceding siblings ...)
  2017-03-04 16:46 ` [PATCH 3/3] staging: vc04_services: " simran singhal
@ 2017-03-04 17:29 ` Julia Lawall
  3 siblings, 0 replies; 5+ messages in thread
From: Julia Lawall @ 2017-03-04 17:29 UTC (permalink / raw)
  To: simran singhal
  Cc: w.d.hubbs, chris, gregkh, devel, linux-kernel, speakup,
	linux-rpi-kernel, outreachy-kernel, linux-arm-kernel



On Sat, 4 Mar 2017, simran singhal wrote:

> This patch series tests if functions like kmalloc/kzalloc return NULL
> on failure. When NULL represents failure, !x is commonly used.
>
> simran singhal (3):
>   staging: rtl8192u: Clean up tests if NULL returned on failure
>   staging: speakup: Clean up tests if NULL returned on failure
>   staging: vc04_services: Clean up tests if NULL returned on failure

Acked-by: Julia Lawall <julia.lawall@lip6.fr>

>
>  drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c      | 2 +-
>  drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c       | 2 +-
>  drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c         | 2 +-
>  drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c              | 4 ++--
>  drivers/staging/speakup/main.c                                 | 2 +-
>  drivers/staging/vc04_services/interface/vchiq_arm/vchiq_util.c | 2 +-
>  6 files changed, 7 insertions(+), 7 deletions(-)
>
> --
> 2.7.4
>
> --
> 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 outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1488646015-7059-1-git-send-email-singhalsimran0%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-03-04 17:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-04 16:46 [PATCH 0/3] staging: Clean up tests if NULL returned on failure simran singhal
2017-03-04 16:46 ` [PATCH 1/3] staging: rtl8192u: " simran singhal
2017-03-04 16:46 ` [PATCH 2/3] staging: speakup: " simran singhal
2017-03-04 16:46 ` [PATCH 3/3] staging: vc04_services: " simran singhal
2017-03-04 17:29 ` [Outreachy kernel] [PATCH 0/3] staging: " Julia Lawall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).