* [PATCH v2] staging: rtl8192e: Clean up tests on the results of functions that return NULL on failure.
@ 2016-03-06 9:18 G Pooja Shamili
2016-03-11 17:25 ` [Outreachy kernel] " Greg KH
0 siblings, 1 reply; 3+ messages in thread
From: G Pooja Shamili @ 2016-03-06 9:18 UTC (permalink / raw)
To: outreachy-kernel
Functions returning NULL as a return value on failure can be tested for
as !x, NULL == x or x == NULL. As !x is commonly used, all the tests
need to be modified to use !x for a consistent coding style. In this
patch, the function kzalloc is considered.
Coccinelle is used to achieve this, the semantic patch being:
@@
expression E;
statement S;
@@
E = kzalloc(...);
if (
(
+ !
E
- == NULL
|
+ !
- NULL ==
E
)
) S
Signed-off-by: G Pooja Shamili <poojashamili@gmail.com>
---
Changes from Version 1:
* Changed the name in the From: and Signed-off-by: to full
name.
drivers/staging/rtl8192e/rtllib_wx.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/rtl8192e/rtllib_wx.c b/drivers/staging/rtl8192e/rtllib_wx.c
index 84e6272..8060410 100644
--- a/drivers/staging/rtl8192e/rtllib_wx.c
+++ b/drivers/staging/rtl8192e/rtllib_wx.c
@@ -373,7 +373,7 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee,
/* take WEP into use */
new_crypt = kzalloc(sizeof(struct lib80211_crypt_data),
GFP_KERNEL);
- if (new_crypt == NULL)
+ if (!new_crypt)
return -ENOMEM;
new_crypt->ops = lib80211_get_crypto_ops("R-WEP");
if (!new_crypt->ops) {
@@ -618,7 +618,7 @@ int rtllib_wx_set_encode_ext(struct rtllib_device *ieee,
lib80211_crypt_delayed_deinit(&ieee->crypt_info, crypt);
new_crypt = kzalloc(sizeof(*new_crypt), GFP_KERNEL);
- if (new_crypt == NULL) {
+ if (!new_crypt) {
ret = -ENOMEM;
goto done;
}
--
2.1.4
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [Outreachy kernel] [PATCH v2] staging: rtl8192e: Clean up tests on the results of functions that return NULL on failure.
2016-03-06 9:18 [PATCH v2] staging: rtl8192e: Clean up tests on the results of functions that return NULL on failure G Pooja Shamili
@ 2016-03-11 17:25 ` Greg KH
0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2016-03-11 17:25 UTC (permalink / raw)
To: G Pooja Shamili; +Cc: outreachy-kernel
On Sun, Mar 06, 2016 at 02:48:58PM +0530, G Pooja Shamili wrote:
> Functions returning NULL as a return value on failure can be tested for
> as !x, NULL == x or x == NULL. As !x is commonly used, all the tests
> need to be modified to use !x for a consistent coding style. In this
> patch, the function kzalloc is considered.
>
> Coccinelle is used to achieve this, the semantic patch being:
>
> @@
> expression E;
> statement S;
> @@
>
> E = kzalloc(...);
>
> if (
> (
> + !
> E
> - == NULL
> |
> + !
> - NULL ==
> E
> )
> ) S
>
> Signed-off-by: G Pooja Shamili <poojashamili@gmail.com>
> ---
> Changes from Version 1:
> * Changed the name in the From: and Signed-off-by: to full
> name.
You sent me 2 patches with pretty much the identical subject line, yet
they all did 3 different things. Please fix up and resend as a patch
series.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2] staging: rtl8192e: Clean up tests on the results of functions that return NULL on failure.
@ 2016-02-27 7:01 pooja.shamili
0 siblings, 0 replies; 3+ messages in thread
From: pooja.shamili @ 2016-02-27 7:01 UTC (permalink / raw)
To: outreachy-kernel
Functions returning NULL as a return value on failure can be tested for
as !x, NULL == x or x == NULL. As !x is commonly used, all the tests
need to be modified to use !x for a consistent coding style. In this
patch, the function kzalloc is considered.
Coccinelle is used to achieve this, the semantic patch being:
@@
expression E;
statement S;
@@
E = kzalloc(...);
if (
(
+ !
E
- == NULL
|
+ !
- NULL ==
E
)
) S
Signed-off-by: pooja.shamili <poojashamili@gmail.com>
---
drivers/staging/rtl8192e/rtllib_wx.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/rtl8192e/rtllib_wx.c b/drivers/staging/rtl8192e/rtllib_wx.c
index 84e6272..8060410 100644
--- a/drivers/staging/rtl8192e/rtllib_wx.c
+++ b/drivers/staging/rtl8192e/rtllib_wx.c
@@ -373,7 +373,7 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee,
/* take WEP into use */
new_crypt = kzalloc(sizeof(struct lib80211_crypt_data),
GFP_KERNEL);
- if (new_crypt == NULL)
+ if (!new_crypt)
return -ENOMEM;
new_crypt->ops = lib80211_get_crypto_ops("R-WEP");
if (!new_crypt->ops) {
@@ -618,7 +618,7 @@ int rtllib_wx_set_encode_ext(struct rtllib_device *ieee,
lib80211_crypt_delayed_deinit(&ieee->crypt_info, crypt);
new_crypt = kzalloc(sizeof(*new_crypt), GFP_KERNEL);
- if (new_crypt == NULL) {
+ if (!new_crypt) {
ret = -ENOMEM;
goto done;
}
--
2.1.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-03-11 17:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-06 9:18 [PATCH v2] staging: rtl8192e: Clean up tests on the results of functions that return NULL on failure G Pooja Shamili
2016-03-11 17:25 ` [Outreachy kernel] " Greg KH
-- strict thread matches above, loose matches on Subject: below --
2016-02-27 7:01 pooja.shamili
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.