Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1223666

[PATCH 13/39] staging: lustre: drop null test before destroy functions

From Julia Lawall <Julia.Lawall@lip6.fr>
Newsgroups linux.kernel
Subject [PATCH 13/39] staging: lustre: drop null test before destroy functions
Date 2015-09-13 14:40 +0200
Message-ID <q8eJC-7J8-61@gated-at.bofh.it> (permalink)
References <q8ezT-7xJ-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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>

---
 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 +----
 3 files changed, 14 insertions(+), 32 deletions(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c
index 8e47232..e8101fe 100644
--- a/drivers/staging/lustre/lustre/obdclass/lu_object.c
+++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c
@@ -2052,10 +2052,8 @@ EXPORT_SYMBOL(lu_kmem_init);
 void lu_kmem_fini(struct lu_kmem_descr *caches)
 {
 	for (; caches->ckd_cache != NULL; ++caches) {
-		if (*caches->ckd_cache != NULL) {
-			kmem_cache_destroy(*caches->ckd_cache);
-			*caches->ckd_cache = NULL;
-		}
+		kmem_cache_destroy(*caches->ckd_cache);
+		*caches->ckd_cache = NULL;
 	}
 }
 EXPORT_SYMBOL(lu_kmem_fini);
diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
index 0ca7309..ad78a04 100644
--- a/drivers/staging/lustre/lustre/obdclass/genops.c
+++ b/drivers/staging/lustre/lustre/obdclass/genops.c
@@ -638,22 +638,14 @@ EXPORT_SYMBOL(class_notify_sptlrpc_conf);
 
 void obd_cleanup_caches(void)
 {
-	if (obd_device_cachep) {
-		kmem_cache_destroy(obd_device_cachep);
-		obd_device_cachep = NULL;
-	}
-	if (obdo_cachep) {
-		kmem_cache_destroy(obdo_cachep);
-		obdo_cachep = NULL;
-	}
-	if (import_cachep) {
-		kmem_cache_destroy(import_cachep);
-		import_cachep = NULL;
-	}
-	if (capa_cachep) {
-		kmem_cache_destroy(capa_cachep);
-		capa_cachep = NULL;
-	}
+	kmem_cache_destroy(obd_device_cachep);
+	obd_device_cachep = NULL;
+	kmem_cache_destroy(obdo_cachep);
+	obdo_cachep = NULL;
+	kmem_cache_destroy(import_cachep);
+	import_cachep = NULL;
+	kmem_cache_destroy(capa_cachep);
+	capa_cachep = NULL;
 }
 
 int obd_init_caches(void)
diff --git a/drivers/staging/lustre/lustre/llite/super25.c b/drivers/staging/lustre/lustre/llite/super25.c
index e4020ce..4cf7af2 100644
--- a/drivers/staging/lustre/lustre/llite/super25.c
+++ b/drivers/staging/lustre/lustre/llite/super25.c
@@ -183,18 +183,10 @@ out_sysfs:
 out_debugfs:
 	debugfs_remove(llite_root);
 out_cache:
-	if (ll_inode_cachep != NULL)
-		kmem_cache_destroy(ll_inode_cachep);
-
-	if (ll_file_data_slab != NULL)
-		kmem_cache_destroy(ll_file_data_slab);
-
-	if (ll_remote_perm_cachep != NULL)
-		kmem_cache_destroy(ll_remote_perm_cachep);
-
-	if (ll_rmtperm_hash_cachep != NULL)
-		kmem_cache_destroy(ll_rmtperm_hash_cachep);
-
+	kmem_cache_destroy(ll_inode_cachep);
+	kmem_cache_destroy(ll_file_data_slab);
+	kmem_cache_destroy(ll_remote_perm_cachep);
+	kmem_cache_destroy(ll_rmtperm_hash_cachep);
 	return rc;
 }
 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 00/39] drop null test before destroy functions Julia Lawall <Julia.Lawall@lip6.fr> - 2015-09-13 14:40 +0200
  [PATCH 04/39] debugobjects: drop null test before destroy functions Julia Lawall <Julia.Lawall@lip6.fr> - 2015-09-13 14:40 +0200
  [PATCH 18/39] whci: drop null test before destroy functions Julia Lawall <Julia.Lawall@lip6.fr> - 2015-09-13 14:40 +0200
  [PATCH 05/39] xhci: drop null test before destroy functions Julia Lawall <Julia.Lawall@lip6.fr> - 2015-09-13 14:40 +0200
  [PATCH 27/39] ocfs2: drop null test before destroy functions Julia Lawall <Julia.Lawall@lip6.fr> - 2015-09-13 14:40 +0200
  [PATCH 28/39] ecryptfs: drop null test before destroy functions Julia Lawall <Julia.Lawall@lip6.fr> - 2015-09-13 14:40 +0200
    Re: [PATCH 28/39] ecryptfs: drop null test before destroy functions Tyler Hicks <tyhicks@canonical.com> - 2015-09-15 04:10 +0200
      Re: [PATCH 28/39] ecryptfs: drop null test before destroy  functions Julia Lawall <julia.lawall@lip6.fr> - 2015-09-15 06:40 +0200
        Re: [PATCH 28/39] ecryptfs: drop null test before destroy functions Tyler Hicks <tyhicks@canonical.com> - 2015-09-15 16:50 +0200
  [PATCH 07/39] fs: ext4: drop null test before destroy functions Julia Lawall <Julia.Lawall@lip6.fr> - 2015-09-13 14:40 +0200
  [PATCH 30/39] block: drop null test before destroy functions Julia Lawall <Julia.Lawall@lip6.fr> - 2015-09-13 14:40 +0200
  [PATCH 13/39] staging: lustre: drop null test before destroy functions Julia Lawall <Julia.Lawall@lip6.fr> - 2015-09-13 14:40 +0200
  [PATCH 29/39] thunderbolt: drop null test before destroy functions Julia Lawall <Julia.Lawall@lip6.fr> - 2015-09-13 14:40 +0200
  Re: [PATCH 00/39] drop null test before destroy functions SF Markus Elfring <elfring@users.sourceforge.net> - 2015-09-14 14:00 +0200

csiph-web