linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/39] drop null test before destroy functions
@ 2015-09-13 12:14 Julia Lawall
  2015-09-13 12:14 ` [PATCH 06/39] Btrfs: " Julia Lawall
  2015-09-14 11:55 ` [PATCH 00/39] " SF Markus Elfring
  0 siblings, 2 replies; 4+ messages in thread
From: Julia Lawall @ 2015-09-13 12:14 UTC (permalink / raw)
  To: iommu, dccp, dri-devel, intel-gfx, ecryptfs, dmaengine
  Cc: sergey.senozhatsky, kernel-janitors, 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-ext4,
	linux-rdma, devel, HPDD-discuss, linux-bcache, drbd-user,
	ocfs2-devel, kvm, ceph-devel, Chao Yu, linux-f2fs-devel

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)

These patches remove the associated NULL tests for the files that I found
easy to compile test.  If these changes are OK, I will address the
remainder later.

---

 arch/x86/kvm/mmu.c                                 |    6 --
 block/bio-integrity.c                              |    7 --
 block/bio.c                                        |    7 --
 block/blk-core.c                                   |    3 -
 block/elevator.c                                   |    3 -
 drivers/atm/he.c                                   |    7 --
 drivers/block/aoe/aoedev.c                         |    3 -
 drivers/block/drbd/drbd_main.c                     |   21 ++-----
 drivers/block/pktcdvd.c                            |    3 -
 drivers/block/rbd.c                                |    6 --
 drivers/dma/dmaengine.c                            |    6 --
 drivers/firmware/google/gsmi.c                     |    3 -
 drivers/gpu/drm/i915/i915_dma.c                    |   19 ++----
 drivers/iommu/amd_iommu_init.c                     |    7 --
 drivers/md/bcache/bset.c                           |    3 -
 drivers/md/bcache/request.c                        |    3 -
 drivers/md/bcache/super.c                          |    9 +--
 drivers/md/dm-bufio.c                              |    3 -
 drivers/md/dm-cache-target.c                       |    3 -
 drivers/md/dm-crypt.c                              |    6 --
 drivers/md/dm-io.c                                 |    3 -
 drivers/md/dm-log-userspace-base.c                 |    3 -
 drivers/md/dm-region-hash.c                        |    4 -
 drivers/md/dm.c                                    |   13 +---
 drivers/md/multipath.c                             |    3 -
 drivers/md/raid1.c                                 |    6 --
 drivers/md/raid10.c                                |    9 +--
 drivers/md/raid5.c                                 |    3 -
 drivers/mtd/nand/nandsim.c                         |    3 -
 drivers/mtd/ubi/attach.c                           |    4 -
 drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c      |    3 -
 drivers/staging/lustre/lustre/llite/super25.c      |   16 +----
 drivers/staging/lustre/lustre/obdclass/genops.c    |   24 ++------
 drivers/staging/lustre/lustre/obdclass/lu_object.c |    6 --
 drivers/staging/rdma/hfi1/user_sdma.c              |    3 -
 drivers/thunderbolt/ctl.c                          |    3 -
 drivers/usb/gadget/udc/bdc/bdc_core.c              |    3 -
 drivers/usb/gadget/udc/gr_udc.c                    |    3 -
 drivers/usb/gadget/udc/mv_u3d_core.c               |    3 -
 drivers/usb/gadget/udc/mv_udc_core.c               |    3 -
 drivers/usb/host/fotg210-hcd.c                     |   12 +---
 drivers/usb/host/fusbh200-hcd.c                    |   12 +---
 drivers/usb/host/whci/init.c                       |    3 -
 drivers/usb/host/xhci-mem.c                        |   12 +---
 fs/btrfs/backref.c                                 |    3 -
 fs/btrfs/delayed-inode.c                           |    3 -
 fs/btrfs/delayed-ref.c                             |   12 +---
 fs/btrfs/disk-io.c                                 |    3 -
 fs/btrfs/extent_io.c                               |    6 --
 fs/btrfs/extent_map.c                              |    3 -
 fs/btrfs/file.c                                    |    3 -
 fs/btrfs/inode.c                                   |   18 ++----
 fs/btrfs/ordered-data.c                            |    3 -
 fs/dlm/memory.c                                    |    6 --
 fs/ecryptfs/main.c                                 |    3 -
 fs/ext4/crypto.c                                   |    9 +--
 fs/ext4/extents_status.c                           |    3 -
 fs/ext4/mballoc.c                                  |    3 -
 fs/f2fs/crypto.c                                   |    9 +--
 fs/gfs2/main.c                                     |   29 ++--------
 fs/jbd2/journal.c                                  |   15 +----
 fs/jbd2/revoke.c                                   |   12 +---
 fs/jbd2/transaction.c                              |    6 --
 fs/jffs2/malloc.c                                  |   27 +++------
 fs/nfsd/nfscache.c                                 |    6 --
 fs/nilfs2/super.c                                  |   12 +---
 fs/ocfs2/dlm/dlmlock.c                             |    3 -
 fs/ocfs2/dlm/dlmmaster.c                           |   16 +----
 fs/ocfs2/super.c                                   |   18 ++----
 fs/ocfs2/uptodate.c                                |    3 -
 lib/debugobjects.c                                 |    3 -
 net/core/sock.c                                    |   12 +---
 net/dccp/ackvec.c                                  |   12 +---
 net/dccp/ccid.c                                    |    3 -
 net/sunrpc/sched.c                                 |   12 +---
 75 files changed, 180 insertions(+), 381 deletions(-)

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

* [PATCH 06/39] Btrfs: 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:14 ` Julia Lawall
  2015-09-14 20:43   ` David Sterba
  2015-09-14 11:55 ` [PATCH 00/39] " SF Markus Elfring
  1 sibling, 1 reply; 4+ messages in thread
From: Julia Lawall @ 2015-09-13 12:14 UTC (permalink / raw)
  To: Chris Mason
  Cc: sergey.senozhatsky, kernel-janitors, Josef Bacik, David Sterba,
	linux-btrfs, 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>

---
 fs/btrfs/backref.c       |    3 +--
 fs/btrfs/delayed-inode.c |    3 +--
 fs/btrfs/delayed-ref.c   |   12 ++++--------
 fs/btrfs/disk-io.c       |    3 +--
 fs/btrfs/extent_io.c     |    6 ++----
 fs/btrfs/extent_map.c    |    3 +--
 fs/btrfs/file.c          |    3 +--
 fs/btrfs/inode.c         |   18 ++++++------------
 fs/btrfs/ordered-data.c  |    3 +--
 9 files changed, 18 insertions(+), 36 deletions(-)

diff --git a/fs/btrfs/extent_map.c b/fs/btrfs/extent_map.c
index 6a98bdd..6416c11 100644
--- a/fs/btrfs/extent_map.c
+++ b/fs/btrfs/extent_map.c
@@ -20,8 +20,7 @@ int __init extent_map_init(void)
 
 void extent_map_exit(void)
 {
-	if (extent_map_cache)
-		kmem_cache_destroy(extent_map_cache);
+	kmem_cache_destroy(extent_map_cache);
 }
 
 /**
diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c
index ac3e81d..54ae98d 100644
--- a/fs/btrfs/delayed-ref.c
+++ b/fs/btrfs/delayed-ref.c
@@ -787,14 +787,10 @@ btrfs_find_delayed_ref_head(struct btrfs_trans_handle *trans, u64 bytenr)
 
 void btrfs_delayed_ref_exit(void)
 {
-	if (btrfs_delayed_ref_head_cachep)
-		kmem_cache_destroy(btrfs_delayed_ref_head_cachep);
-	if (btrfs_delayed_tree_ref_cachep)
-		kmem_cache_destroy(btrfs_delayed_tree_ref_cachep);
-	if (btrfs_delayed_data_ref_cachep)
-		kmem_cache_destroy(btrfs_delayed_data_ref_cachep);
-	if (btrfs_delayed_extent_op_cachep)
-		kmem_cache_destroy(btrfs_delayed_extent_op_cachep);
+	kmem_cache_destroy(btrfs_delayed_ref_head_cachep);
+	kmem_cache_destroy(btrfs_delayed_tree_ref_cachep);
+	kmem_cache_destroy(btrfs_delayed_data_ref_cachep);
+	kmem_cache_destroy(btrfs_delayed_extent_op_cachep);
 }
 
 int btrfs_delayed_ref_init(void)
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 0d98aee..6cc044d 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -103,8 +103,7 @@ int __init btrfs_end_io_wq_init(void)
 
 void btrfs_end_io_wq_exit(void)
 {
-	if (btrfs_end_io_wq_cache)
-		kmem_cache_destroy(btrfs_end_io_wq_cache);
+	kmem_cache_destroy(btrfs_end_io_wq_cache);
 }
 
 /*
diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index a2ae427..1fb6ce3 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -43,8 +43,7 @@ int __init btrfs_delayed_inode_init(void)
 
 void btrfs_delayed_inode_exit(void)
 {
-	if (delayed_node_cache)
-		kmem_cache_destroy(delayed_node_cache);
+	kmem_cache_destroy(delayed_node_cache);
 }
 
 static inline void btrfs_init_delayed_node(
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index b823fac..c8d0210 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -2820,8 +2820,7 @@ const struct file_operations btrfs_file_operations = {
 
 void btrfs_auto_defrag_exit(void)
 {
-	if (btrfs_inode_defrag_cachep)
-		kmem_cache_destroy(btrfs_inode_defrag_cachep);
+	kmem_cache_destroy(btrfs_inode_defrag_cachep);
 }
 
 int btrfs_auto_defrag_init(void)
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c
index 52170cf..2e5a1e1 100644
--- a/fs/btrfs/ordered-data.c
+++ b/fs/btrfs/ordered-data.c
@@ -1072,6 +1072,5 @@ int __init ordered_data_init(void)
 
 void ordered_data_exit(void)
 {
-	if (btrfs_ordered_extent_cache)
-		kmem_cache_destroy(btrfs_ordered_extent_cache);
+	kmem_cache_destroy(btrfs_ordered_extent_cache);
 }
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index a0fa725..c7904d3 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -9031,18 +9031,12 @@ void btrfs_destroy_cachep(void)
 	 * destroy cache.
 	 */
 	rcu_barrier();
-	if (btrfs_inode_cachep)
-		kmem_cache_destroy(btrfs_inode_cachep);
-	if (btrfs_trans_handle_cachep)
-		kmem_cache_destroy(btrfs_trans_handle_cachep);
-	if (btrfs_transaction_cachep)
-		kmem_cache_destroy(btrfs_transaction_cachep);
-	if (btrfs_path_cachep)
-		kmem_cache_destroy(btrfs_path_cachep);
-	if (btrfs_free_space_cachep)
-		kmem_cache_destroy(btrfs_free_space_cachep);
-	if (btrfs_delalloc_work_cachep)
-		kmem_cache_destroy(btrfs_delalloc_work_cachep);
+	kmem_cache_destroy(btrfs_inode_cachep);
+	kmem_cache_destroy(btrfs_trans_handle_cachep);
+	kmem_cache_destroy(btrfs_transaction_cachep);
+	kmem_cache_destroy(btrfs_path_cachep);
+	kmem_cache_destroy(btrfs_free_space_cachep);
+	kmem_cache_destroy(btrfs_delalloc_work_cachep);
 }
 
 int btrfs_init_cachep(void)
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index ecbc63d..6763b1f 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -148,8 +148,7 @@ int __init btrfs_prelim_ref_init(void)
 
 void btrfs_prelim_ref_exit(void)
 {
-	if (btrfs_prelim_ref_cache)
-		kmem_cache_destroy(btrfs_prelim_ref_cache);
+	kmem_cache_destroy(btrfs_prelim_ref_cache);
 }
 
 /*
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index f1018cf..b538b3e 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -187,10 +187,8 @@ void extent_io_exit(void)
 	 * destroy caches.
 	 */
 	rcu_barrier();
-	if (extent_state_cache)
-		kmem_cache_destroy(extent_state_cache);
-	if (extent_buffer_cache)
-		kmem_cache_destroy(extent_buffer_cache);
+	kmem_cache_destroy(extent_state_cache);
+	kmem_cache_destroy(extent_buffer_cache);
 	if (btrfs_bioset)
 		bioset_free(btrfs_bioset);
 }


^ permalink raw reply related	[flat|nested] 4+ 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
  2015-09-13 12:14 ` [PATCH 06/39] Btrfs: " Julia Lawall
@ 2015-09-14 11:55 ` SF Markus Elfring
  1 sibling, 0 replies; 4+ 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-ext4, linux-rdma, devel,
	HPDD-discuss, linux-bcache, drbd-user, ocfs2-devel, kvm,
	ceph-devel, Chao Yu, linux-f2fs-devel

> 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] 4+ messages in thread

* Re: [PATCH 06/39] Btrfs: drop null test before destroy functions
  2015-09-13 12:14 ` [PATCH 06/39] Btrfs: " Julia Lawall
@ 2015-09-14 20:43   ` David Sterba
  0 siblings, 0 replies; 4+ messages in thread
From: David Sterba @ 2015-09-14 20:43 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Chris Mason, sergey.senozhatsky, kernel-janitors, Josef Bacik,
	David Sterba, linux-btrfs, linux-kernel

On Sun, Sep 13, 2015 at 02:14:59PM +0200, Julia Lawall wrote:
> 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>

Acked-by: David Sterba <dsterba@suse.com>

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

end of thread, other threads:[~2015-09-14 20:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-13 12:14 [PATCH 00/39] drop null test before destroy functions Julia Lawall
2015-09-13 12:14 ` [PATCH 06/39] Btrfs: " Julia Lawall
2015-09-14 20:43   ` David Sterba
2015-09-14 11:55 ` [PATCH 00/39] " SF Markus Elfring

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).