staging: lustre: drop null test before destroy functions
authorJulia Lawall <Julia.Lawall@lip6.fr>
Sun, 13 Sep 2015 12:15:06 +0000 (14:15 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 14 Sep 2015 15:50:44 +0000 (08:50 -0700)
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/llite/super25.c
drivers/staging/lustre/lustre/obdclass/genops.c
drivers/staging/lustre/lustre/obdclass/lu_object.c

index e4020ce8cb7b85d8c771f42b05cc9c77335709cd..4cf7af226ad7110091400232c0ffdbefd35a86f5 100644 (file)
@@ -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;
 }
 
index 64af0abd970de486caffe4355a49d2b2f4e757b0..370d5b4af19b3636e13759f7c709b896cde19ebc 100644 (file)
@@ -639,22 +639,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)
index 48d543682144d61997f67256aeb8443e6d9cdf98..3111982f69c2ff29c6ea93d3b1a53682e398eb38 100644 (file)
@@ -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);