* [PATCH 10/39] atm: he: drop null test before destroy functions
2015-09-13 12:14 [PATCH 00/39] drop null test before destroy functions Julia Lawall
@ 2015-09-13 12:15 ` Julia Lawall
2015-09-15 23:50 ` David Miller
2015-09-13 12:15 ` [PATCH 14/39] SUNRPC: " Julia Lawall
` (4 subsequent siblings)
5 siblings, 1 reply; 12+ messages in thread
From: Julia Lawall @ 2015-09-13 12:15 UTC (permalink / raw)
To: Chas Williams
Cc: sergey.senozhatsky, kernel-janitors, linux-atm-general, netdev,
linux-kernel
Remove unneeded NULL test.
The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@ expression x; @@
-if (x != NULL)
\(kmem_cache_destroy\|mempool_destroy\|dma_pool_destroy\)(x);
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6•fr>
---
drivers/atm/he.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/atm/he.c b/drivers/atm/he.c
index a8da3a5..0f5cb37 100644
--- a/drivers/atm/he.c
+++ b/drivers/atm/he.c
@@ -1578,9 +1578,7 @@ he_stop(struct he_dev *he_dev)
kfree(he_dev->rbpl_virt);
kfree(he_dev->rbpl_table);
-
- if (he_dev->rbpl_pool)
- dma_pool_destroy(he_dev->rbpl_pool);
+ dma_pool_destroy(he_dev->rbpl_pool);
if (he_dev->rbrq_base)
dma_free_coherent(&he_dev->pci_dev->dev, CONFIG_RBRQ_SIZE * sizeof(struct he_rbrq),
@@ -1594,8 +1592,7 @@ he_stop(struct he_dev *he_dev)
dma_free_coherent(&he_dev->pci_dev->dev, CONFIG_TBRQ_SIZE * sizeof(struct he_tbrq),
he_dev->tpdrq_base, he_dev->tpdrq_phys);
- if (he_dev->tpd_pool)
- dma_pool_destroy(he_dev->tpd_pool);
+ dma_pool_destroy(he_dev->tpd_pool);
if (he_dev->pci_dev) {
pci_read_config_word(he_dev->pci_dev, PCI_COMMAND, &command);
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCH 10/39] atm: he: drop null test before destroy functions
2015-09-13 12:15 ` [PATCH 10/39] atm: he: " Julia Lawall
@ 2015-09-15 23:50 ` David Miller
0 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2015-09-15 23:50 UTC (permalink / raw)
To: Julia.Lawall
Cc: 3chas3, sergey.senozhatsky, kernel-janitors, linux-atm-general,
netdev, linux-kernel
From: Julia Lawall <Julia.Lawall@lip6•fr>
Date: Sun, 13 Sep 2015 14:15:03 +0200
> Remove unneeded NULL test.
>
> The semantic patch that makes this change is as follows:
> (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @@ expression x; @@
> -if (x != NULL)
> \(kmem_cache_destroy\|mempool_destroy\|dma_pool_destroy\)(x);
> // </smpl>
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6•fr>
Applied.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 14/39] SUNRPC: drop null test before destroy functions
2015-09-13 12:14 [PATCH 00/39] drop null test before destroy functions Julia Lawall
2015-09-13 12:15 ` [PATCH 10/39] atm: he: " Julia Lawall
@ 2015-09-13 12:15 ` Julia Lawall
[not found] ` <1442146532-9100-15-git-send-email-Julia.Lawall-L2FTfq7BK8M@public.gmane.org>
2015-09-13 12:15 ` [PATCH 20/39] ixgbe: " Julia Lawall
` (3 subsequent siblings)
5 siblings, 1 reply; 12+ messages in thread
From: Julia Lawall @ 2015-09-13 12:15 UTC (permalink / raw)
To: J. Bruce Fields
Cc: sergey.senozhatsky, kernel-janitors, Jeff Layton, Trond Myklebust,
Anna Schumaker, David S. Miller, linux-nfs, netdev, linux-kernel
Remove unneeded NULL test.
The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@ expression x; @@
-if (x != NULL)
\(kmem_cache_destroy\|mempool_destroy\|dma_pool_destroy\)(x);
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6•fr>
---
net/sunrpc/sched.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
index b140c09..425ca2f 100644
--- a/net/sunrpc/sched.c
+++ b/net/sunrpc/sched.c
@@ -1092,14 +1092,10 @@ void
rpc_destroy_mempool(void)
{
rpciod_stop();
- if (rpc_buffer_mempool)
- mempool_destroy(rpc_buffer_mempool);
- if (rpc_task_mempool)
- mempool_destroy(rpc_task_mempool);
- if (rpc_task_slabp)
- kmem_cache_destroy(rpc_task_slabp);
- if (rpc_buffer_slabp)
- kmem_cache_destroy(rpc_buffer_slabp);
+ mempool_destroy(rpc_buffer_mempool);
+ mempool_destroy(rpc_task_mempool);
+ kmem_cache_destroy(rpc_task_slabp);
+ kmem_cache_destroy(rpc_buffer_slabp);
rpc_destroy_wait_queue(&delay_queue);
}
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 20/39] ixgbe: drop null test before destroy functions
2015-09-13 12:14 [PATCH 00/39] drop null test before destroy functions Julia Lawall
2015-09-13 12:15 ` [PATCH 10/39] atm: he: " Julia Lawall
2015-09-13 12:15 ` [PATCH 14/39] SUNRPC: " Julia Lawall
@ 2015-09-13 12:15 ` Julia Lawall
2015-09-13 12:15 ` [PATCH 25/39] net: core: " Julia Lawall
` (2 subsequent siblings)
5 siblings, 0 replies; 12+ messages in thread
From: Julia Lawall @ 2015-09-13 12:15 UTC (permalink / raw)
To: Jeff Kirsher
Cc: sergey.senozhatsky, kernel-janitors, Jesse Brandeburg,
Shannon Nelson, Carolyn Wyborny, Don Skidmore, Matthew Vick,
John Ronciak, Mitch Williams, intel-wired-lan, netdev,
linux-kernel
Remove unneeded NULL test.
The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@ expression x; @@
-if (x != NULL)
\(kmem_cache_destroy\|mempool_destroy\|dma_pool_destroy\)(x);
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6•fr>
---
drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c
index 631c603..5f98870 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c
@@ -620,8 +620,7 @@ static void ixgbe_fcoe_dma_pool_free(struct ixgbe_fcoe *fcoe, unsigned int cpu)
struct ixgbe_fcoe_ddp_pool *ddp_pool;
ddp_pool = per_cpu_ptr(fcoe->ddp_pool, cpu);
- if (ddp_pool->pool)
- dma_pool_destroy(ddp_pool->pool);
+ dma_pool_destroy(ddp_pool->pool);
ddp_pool->pool = NULL;
}
^ permalink raw reply related [flat|nested] 12+ messages in thread* [PATCH 25/39] net: core: drop null test before destroy functions
2015-09-13 12:14 [PATCH 00/39] drop null test before destroy functions Julia Lawall
` (2 preceding siblings ...)
2015-09-13 12:15 ` [PATCH 20/39] ixgbe: " Julia Lawall
@ 2015-09-13 12:15 ` Julia Lawall
2015-09-15 23:50 ` David Miller
2015-09-13 12:15 ` [PATCH 34/39] dccp: " Julia Lawall
2015-09-14 11:55 ` [PATCH 00/39] " SF Markus Elfring
5 siblings, 1 reply; 12+ messages in thread
From: Julia Lawall @ 2015-09-13 12:15 UTC (permalink / raw)
To: David S. Miller; +Cc: sergey.senozhatsky, kernel-janitors, netdev, linux-kernel
Remove unneeded NULL test.
The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@ expression x; @@
-if (x != NULL) {
\(kmem_cache_destroy\|mempool_destroy\|dma_pool_destroy\)(x);
x = NULL;
-}
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6•fr>
---
net/core/sock.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/net/core/sock.c b/net/core/sock.c
index ca2984a..3307c02 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -2740,10 +2740,8 @@ static void req_prot_cleanup(struct request_sock_ops *rsk_prot)
return;
kfree(rsk_prot->slab_name);
rsk_prot->slab_name = NULL;
- if (rsk_prot->slab) {
- kmem_cache_destroy(rsk_prot->slab);
- rsk_prot->slab = NULL;
- }
+ kmem_cache_destroy(rsk_prot->slab);
+ rsk_prot->slab = NULL;
}
static int req_prot_init(const struct proto *prot)
@@ -2828,10 +2826,8 @@ void proto_unregister(struct proto *prot)
list_del(&prot->node);
mutex_unlock(&proto_list_mutex);
- if (prot->slab != NULL) {
- kmem_cache_destroy(prot->slab);
- prot->slab = NULL;
- }
+ kmem_cache_destroy(prot->slab);
+ prot->slab = NULL;
req_prot_cleanup(prot->rsk_prot);
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCH 25/39] net: core: drop null test before destroy functions
2015-09-13 12:15 ` [PATCH 25/39] net: core: " Julia Lawall
@ 2015-09-15 23:50 ` David Miller
0 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2015-09-15 23:50 UTC (permalink / raw)
To: Julia.Lawall; +Cc: sergey.senozhatsky, kernel-janitors, netdev, linux-kernel
From: Julia Lawall <Julia.Lawall@lip6•fr>
Date: Sun, 13 Sep 2015 14:15:18 +0200
> Remove unneeded NULL test.
>
> The semantic patch that makes this change is as follows:
> (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @@ expression x; @@
> -if (x != NULL) {
> \(kmem_cache_destroy\|mempool_destroy\|dma_pool_destroy\)(x);
> x = NULL;
> -}
> // </smpl>
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6•fr>
Applied.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH 34/39] dccp: drop null test before destroy functions
2015-09-13 12:14 [PATCH 00/39] drop null test before destroy functions Julia Lawall
` (3 preceding siblings ...)
2015-09-13 12:15 ` [PATCH 25/39] net: core: " Julia Lawall
@ 2015-09-13 12:15 ` Julia Lawall
2015-09-15 23:50 ` David Miller
2015-09-14 11:55 ` [PATCH 00/39] " SF Markus Elfring
5 siblings, 1 reply; 12+ messages in thread
From: Julia Lawall @ 2015-09-13 12:15 UTC (permalink / raw)
To: Gerrit Renker
Cc: sergey.senozhatsky, kernel-janitors, David S. Miller, dccp,
netdev, linux-kernel
Remove unneeded NULL test.
The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@
expression x;
@@
-if (x != NULL)
\(kmem_cache_destroy\|mempool_destroy\|dma_pool_destroy\)(x);
@@
expression x;
@@
-if (x != NULL) {
\(kmem_cache_destroy\|mempool_destroy\|dma_pool_destroy\)(x);
x = NULL;
-}
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6•fr>
---
net/dccp/ackvec.c | 12 ++++--------
net/dccp/ccid.c | 3 +--
2 files changed, 5 insertions(+), 10 deletions(-)
diff --git a/net/dccp/ccid.c b/net/dccp/ccid.c
index 8349897..90f77d0 100644
--- a/net/dccp/ccid.c
+++ b/net/dccp/ccid.c
@@ -95,8 +95,7 @@ static struct kmem_cache *ccid_kmem_cache_create(int obj_size, char *slab_name_f
static void ccid_kmem_cache_destroy(struct kmem_cache *slab)
{
- if (slab != NULL)
- kmem_cache_destroy(slab);
+ kmem_cache_destroy(slab);
}
static int __init ccid_activate(struct ccid_operations *ccid_ops)
diff --git a/net/dccp/ackvec.c b/net/dccp/ackvec.c
index bd9e718..3de0d03 100644
--- a/net/dccp/ackvec.c
+++ b/net/dccp/ackvec.c
@@ -398,12 +398,8 @@ out_err:
void dccp_ackvec_exit(void)
{
- if (dccp_ackvec_slab != NULL) {
- kmem_cache_destroy(dccp_ackvec_slab);
- dccp_ackvec_slab = NULL;
- }
- if (dccp_ackvec_record_slab != NULL) {
- kmem_cache_destroy(dccp_ackvec_record_slab);
- dccp_ackvec_record_slab = NULL;
- }
+ kmem_cache_destroy(dccp_ackvec_slab);
+ dccp_ackvec_slab = NULL;
+ kmem_cache_destroy(dccp_ackvec_record_slab);
+ dccp_ackvec_record_slab = NULL;
}
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [PATCH 34/39] dccp: drop null test before destroy functions
2015-09-13 12:15 ` [PATCH 34/39] dccp: " Julia Lawall
@ 2015-09-15 23:50 ` David Miller
0 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2015-09-15 23:50 UTC (permalink / raw)
To: Julia.Lawall
Cc: gerrit, sergey.senozhatsky, kernel-janitors, dccp, netdev,
linux-kernel
From: Julia Lawall <Julia.Lawall@lip6•fr>
Date: Sun, 13 Sep 2015 14:15:27 +0200
> Remove unneeded NULL test.
>
> The semantic patch that makes this change is as follows:
> (http://coccinelle.lip6.fr/)
>
> // <smpl>
> @@
> expression x;
> @@
>
> -if (x != NULL)
> \(kmem_cache_destroy\|mempool_destroy\|dma_pool_destroy\)(x);
>
> @@
> expression x;
> @@
>
> -if (x != NULL) {
> \(kmem_cache_destroy\|mempool_destroy\|dma_pool_destroy\)(x);
> x = NULL;
> -}
> // </smpl>
>
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6•fr>
Applied.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH 00/39] drop null test before destroy functions
2015-09-13 12:14 [PATCH 00/39] drop null test before destroy functions Julia Lawall
` (4 preceding siblings ...)
2015-09-13 12:15 ` [PATCH 34/39] dccp: " Julia Lawall
@ 2015-09-14 11:55 ` SF Markus Elfring
5 siblings, 0 replies; 12+ messages in thread
From: SF Markus Elfring @ 2015-09-14 11:55 UTC (permalink / raw)
To: Julia Lawall, kernel-janitors
Cc: iommu, dccp, dri-devel, intel-gfx, ecryptfs, dmaengine,
sergey.senozhatsky, Dan Williams, cluster-devel, intel-wired-lan,
Mitch Williams, John Ronciak, Matthew Vick, Don Skidmore,
Carolyn Wyborny, Shannon Nelson, Jesse Brandeburg, linux-nfs,
linux-raid, netdev, linux-atm-general, linux-btrfs, linux-nilfs,
linux-kernel, linux-mtd, linux-usb, linux
> Recent commits to kernel/git/torvalds/linux.git have made the following
> functions able to tolerate NULL arguments:
>
> kmem_cache_destroy (commit 3942d29918522)
> mempool_destroy (commit 4e3ca3e033d1)
> dma_pool_destroy (commit 44d7175da6ea)
How do you think about to extend an other SmPL script?
Related topic:
scripts/coccinelle/free: Delete NULL test before freeing functions
https://systeme.lip6.fr/pipermail/cocci/2015-May/001960.html
https://www.mail-archive.com/cocci@systeme.lip6.fr/msg01855.html
> If these changes are OK, I will address the remainder later.
Would anybody like to reuse my general SmPL approach for similar source
code clean-up?
Regards,
Markus
^ permalink raw reply [flat|nested] 12+ messages in thread