* [PATCH 0/2] Clean up tests if NULL returned on failure
@ 2017-03-03 18:55 simran singhal
2017-03-03 18:55 ` [PATCH 1/2] staging: media: " simran singhal
2017-03-03 18:55 ` [PATCH 2/2] staging: rtl8192e: " simran singhal
0 siblings, 2 replies; 4+ messages in thread
From: simran singhal @ 2017-03-03 18:55 UTC (permalink / raw)
To: Larry.Finger
Cc: florian.c.schilhabel, gregkh, devel, linux-kernel, outreachy-kernel
This patch series tests if functions like kmalloc/kzalloc return NULL
on failure. When NULL represents failure, !x is commonly used.
simran singhal (2):
staging: media: Clean up tests if NULL returned on failure
staging: rtl8192e: Clean up tests if NULL returned on failure
drivers/staging/media/atomisp/pci/atomisp2/atomisp_fops.c | 2 +-
drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c | 4 ++--
drivers/staging/media/lirc/lirc_zilog.c | 6 +++---
drivers/staging/rtl8192e/rtllib_crypt_ccmp.c | 2 +-
drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 2 +-
drivers/staging/rtl8192e/rtllib_crypt_wep.c | 2 +-
drivers/staging/rtl8192e/rtllib_softmac.c | 2 +-
drivers/staging/rtl8192e/rtllib_wx.c | 4 ++--
8 files changed, 12 insertions(+), 12 deletions(-)
--
2.7.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] staging: media: Clean up tests if NULL returned on failure
2017-03-03 18:55 [PATCH 0/2] Clean up tests if NULL returned on failure simran singhal
@ 2017-03-03 18:55 ` simran singhal
2017-03-09 16:46 ` Greg KH
2017-03-03 18:55 ` [PATCH 2/2] staging: rtl8192e: " simran singhal
1 sibling, 1 reply; 4+ messages in thread
From: simran singhal @ 2017-03-03 18:55 UTC (permalink / raw)
To: Larry.Finger
Cc: florian.c.schilhabel, gregkh, devel, linux-kernel, outreachy-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/media/atomisp/pci/atomisp2/atomisp_fops.c | 2 +-
drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c | 4 ++--
drivers/staging/media/lirc/lirc_zilog.c | 6 +++---
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_fops.c b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_fops.c
index 20e581e..e5a7407 100644
--- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_fops.c
+++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_fops.c
@@ -1100,7 +1100,7 @@ int atomisp_videobuf_mmap_mapper(struct videobuf_queue *q,
continue;
map = kzalloc(sizeof(struct videobuf_mapping), GFP_KERNEL);
- if (map == NULL) {
+ if (!map) {
mutex_unlock(&q->vb_lock);
return -ENOMEM;
}
diff --git a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c
index 32109cd..bffe215 100644
--- a/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c
+++ b/drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c
@@ -228,7 +228,7 @@ static int vpfe_enable_clock(struct vpfe_device *vpfe_dev)
vpfe_dev->clks = kcalloc(vpfe_cfg->num_clocks,
sizeof(*vpfe_dev->clks), GFP_KERNEL);
- if (vpfe_dev->clks == NULL)
+ if (!vpfe_dev->clks)
return -ENOMEM;
for (i = 0; i < vpfe_cfg->num_clocks; i++) {
@@ -348,7 +348,7 @@ static int register_i2c_devices(struct vpfe_device *vpfe_dev)
vpfe_dev->sd =
kcalloc(num_subdevs, sizeof(struct v4l2_subdev *),
GFP_KERNEL);
- if (vpfe_dev->sd == NULL)
+ if (!vpfe_dev->sd)
return -ENOMEM;
for (i = 0, k = 0; i < num_subdevs; i++) {
diff --git a/drivers/staging/media/lirc/lirc_zilog.c b/drivers/staging/media/lirc/lirc_zilog.c
index 34aac3e..4836182 100644
--- a/drivers/staging/media/lirc/lirc_zilog.c
+++ b/drivers/staging/media/lirc/lirc_zilog.c
@@ -1475,7 +1475,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
ir = get_ir_device_by_adapter(adap);
if (ir == NULL) {
ir = kzalloc(sizeof(struct IR), GFP_KERNEL);
- if (ir == NULL) {
+ if (!ir) {
ret = -ENOMEM;
goto out_no_ir;
}
@@ -1515,7 +1515,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
/* Set up a struct IR_tx instance */
tx = kzalloc(sizeof(struct IR_tx), GFP_KERNEL);
- if (tx == NULL) {
+ if (!tx) {
ret = -ENOMEM;
goto out_put_xx;
}
@@ -1559,7 +1559,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
/* Set up a struct IR_rx instance */
rx = kzalloc(sizeof(struct IR_rx), GFP_KERNEL);
- if (rx == NULL) {
+ if (!rx) {
ret = -ENOMEM;
goto out_put_xx;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] staging: rtl8192e: Clean up tests if NULL returned on failure
2017-03-03 18:55 [PATCH 0/2] Clean up tests if NULL returned on failure simran singhal
2017-03-03 18:55 ` [PATCH 1/2] staging: media: " simran singhal
@ 2017-03-03 18:55 ` simran singhal
1 sibling, 0 replies; 4+ messages in thread
From: simran singhal @ 2017-03-03 18:55 UTC (permalink / raw)
To: Larry.Finger
Cc: florian.c.schilhabel, gregkh, devel, linux-kernel, outreachy-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/rtl8192e/rtllib_crypt_ccmp.c | 2 +-
drivers/staging/rtl8192e/rtllib_crypt_tkip.c | 2 +-
drivers/staging/rtl8192e/rtllib_crypt_wep.c | 2 +-
drivers/staging/rtl8192e/rtllib_softmac.c | 2 +-
drivers/staging/rtl8192e/rtllib_wx.c | 4 ++--
5 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
index bc45cf0..ed2e06f 100644
--- a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
+++ b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
@@ -63,7 +63,7 @@ static void *rtllib_ccmp_init(int key_idx)
struct rtllib_ccmp_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/rtl8192e/rtllib_crypt_tkip.c b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
index ae103b0..580b57a 100644
--- a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
+++ b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
@@ -63,7 +63,7 @@ static void *rtllib_tkip_init(int key_idx)
struct rtllib_tkip_data *priv;
priv = kzalloc(sizeof(*priv), GFP_ATOMIC);
- if (priv == NULL)
+ if (!priv)
goto fail;
priv->key_idx = key_idx;
priv->tx_tfm_arc4 = crypto_alloc_skcipher("ecb(arc4)", 0,
diff --git a/drivers/staging/rtl8192e/rtllib_crypt_wep.c b/drivers/staging/rtl8192e/rtllib_crypt_wep.c
index b3343a5..f5a1bc5 100644
--- a/drivers/staging/rtl8192e/rtllib_crypt_wep.c
+++ b/drivers/staging/rtl8192e/rtllib_crypt_wep.c
@@ -37,7 +37,7 @@ static void *prism2_wep_init(int keyidx)
struct prism2_wep_data *priv;
priv = kzalloc(sizeof(*priv), GFP_ATOMIC);
- if (priv == NULL)
+ if (!priv)
goto fail;
priv->key_idx = keyidx;
diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c
index eeda17d..4bdc3ba 100644
--- a/drivers/staging/rtl8192e/rtllib_softmac.c
+++ b/drivers/staging/rtl8192e/rtllib_softmac.c
@@ -3328,7 +3328,7 @@ static int rtllib_wpa_set_encryption(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;
}
diff --git a/drivers/staging/rtl8192e/rtllib_wx.c b/drivers/staging/rtl8192e/rtllib_wx.c
index b1500ee..9f3824a 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.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] staging: media: Clean up tests if NULL returned on failure
2017-03-03 18:55 ` [PATCH 1/2] staging: media: " simran singhal
@ 2017-03-09 16:46 ` Greg KH
0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2017-03-09 16:46 UTC (permalink / raw)
To: simran singhal
Cc: Larry.Finger, devel, florian.c.schilhabel, outreachy-kernel,
linux-kernel
On Sat, Mar 04, 2017 at 12:25:18AM +0530, simran singhal wrote:
> 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/media/atomisp/pci/atomisp2/atomisp_fops.c | 2 +-
> drivers/staging/media/davinci_vpfe/vpfe_mc_capture.c | 4 ++--
> drivers/staging/media/lirc/lirc_zilog.c | 6 +++---
> 3 files changed, 6 insertions(+), 6 deletions(-)
Please break this up into one patch per driver.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-03-09 16:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-03 18:55 [PATCH 0/2] Clean up tests if NULL returned on failure simran singhal
2017-03-03 18:55 ` [PATCH 1/2] staging: media: " simran singhal
2017-03-09 16:46 ` Greg KH
2017-03-03 18:55 ` [PATCH 2/2] staging: rtl8192e: " simran singhal
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.