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


Groups > linux.kernel > #1450796

[PATCH 02/12] staging: lustre: Delete unnecessary checks before the function call "kobject_put"

From SF Markus Elfring <elfring@users.sourceforge.net>
Newsgroups linux.kernel
Subject [PATCH 02/12] staging: lustre: Delete unnecessary checks before the function call "kobject_put"
Date 2016-07-26 21:10 +0200
Message-ID <rZfTP-5XI-5@gated-at.bofh.it> (permalink)
References (1 earlier) <qFfce-yf-5@gated-at.bofh.it> <qIe0h-220-1@gated-at.bofh.it> <qIe9X-25k-7@gated-at.bofh.it> <qIinh-4Eb-35@gated-at.bofh.it> <rZfK9-5Fs-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 26 Jul 2016 13:00:32 +0200

The kobject_put() function tests whether its argument is NULL and then
returns immediately. Thus the test around the calls is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 4 +---
 drivers/staging/lustre/lustre/lmv/lmv_obd.c     | 5 ++---
 drivers/staging/lustre/lustre/lov/lov_obd.c     | 4 +---
 drivers/staging/lustre/lustre/obdclass/genops.c | 6 ++----
 4 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
index 2c1c2fc..52c5dd4 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
@@ -1069,9 +1069,7 @@ static int ldlm_cleanup(void)
 
 	kset_unregister(ldlm_ns_kset);
 	kset_unregister(ldlm_svc_kset);
-	if (ldlm_kobj)
-		kobject_put(ldlm_kobj);
-
+	kobject_put(ldlm_kobj);
 	ldlm_debugfs_cleanup();
 
 	kfree(ldlm_state);
diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
index 0e1588a..8c2e5b3 100644
--- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c
+++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
@@ -238,7 +238,7 @@ static int lmv_connect(const struct lu_env *env,
 	if (data && data->ocd_connect_flags & OBD_CONNECT_REAL)
 		rc = lmv_check_connect(obd);
 
-	if (rc && lmv->lmv_tgts_kobj)
+	if (rc)
 		kobject_put(lmv->lmv_tgts_kobj);
 
 	return rc;
@@ -648,8 +648,7 @@ static int lmv_disconnect(struct obd_export *exp)
 		lmv_disconnect_mdc(obd, lmv->tgts[i]);
 	}
 
-	if (lmv->lmv_tgts_kobj)
-		kobject_put(lmv->lmv_tgts_kobj);
+	kobject_put(lmv->lmv_tgts_kobj);
 
 out_local:
 	/*
diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c
index 9b92d55..df701f7 100644
--- a/drivers/staging/lustre/lustre/lov/lov_obd.c
+++ b/drivers/staging/lustre/lustre/lov/lov_obd.c
@@ -106,9 +106,7 @@ static void lov_putref(struct obd_device *obd)
 			__lov_del_obd(obd, tgt);
 		}
 
-		if (lov->lov_tgts_kobj)
-			kobject_put(lov->lov_tgts_kobj);
-
+		kobject_put(lov->lov_tgts_kobj);
 	} else {
 		mutex_unlock(&lov->lov_lock);
 	}
diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
index 99c2da6..1b5aa9b 100644
--- a/drivers/staging/lustre/lustre/obdclass/genops.c
+++ b/drivers/staging/lustre/lustre/obdclass/genops.c
@@ -203,8 +203,7 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
 	return 0;
 
  failed:
-	if (type->typ_kobj)
-		kobject_put(type->typ_kobj);
+	kobject_put(type->typ_kobj);
 	kfree(type->typ_name);
 	kfree(type->typ_md_ops);
 	kfree(type->typ_dt_ops);
@@ -231,8 +230,7 @@ int class_unregister_type(const char *name)
 		return -EBUSY;
 	}
 
-	if (type->typ_kobj)
-		kobject_put(type->typ_kobj);
+	kobject_put(type->typ_kobj);
 
 	if (!IS_ERR_OR_NULL(type->typ_debugfs_entry))
 		ldebugfs_remove(&type->typ_debugfs_entry);
-- 
2.9.2

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


Thread

[PATCH 00/12] staging-Lustre: Fine-tuning for seven function  implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2016-07-26 21:00 +0200
  [PATCH 01/12] staging/lustre/ldlm: Delete unnecessary checks before  the function call "kset_unregister" SF Markus Elfring <elfring@users.sourceforge.net> - 2016-07-26 21:00 +0200
  [PATCH 04/12] staging: lustre: Split a condition check in  class_register_type() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-07-26 21:10 +0200
  [PATCH 06/12] staging: lustre: Return directly after a failed  kcalloc() in mgc_process_recover_log() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-07-26 21:10 +0200
  [PATCH 02/12] staging: lustre: Delete unnecessary checks before the  function call "kobject_put" SF Markus Elfring <elfring@users.sourceforge.net> - 2016-07-26 21:10 +0200
  [PATCH 07/12] staging: lustre: Less checks after a failed  alloc_page() in mgc_process_recover_log() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-07-26 21:10 +0200
  [PATCH 08/12] staging: lustre: Less checks after a failed  ptlrpc_request_alloc() in mgc_process_recover_log() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-07-26 21:10 +0200
  [PATCH 05/12] staging: lustre: Optimize error handling in  class_register_type() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-07-26 21:10 +0200
    Re: [PATCH 05/12] staging: lustre: Optimize error handling in class_register_type() Oleg Drokin <oleg.drokin@intel.com> - 2016-07-26 21:20 +0200
      Re: [lustre-devel] [PATCH 05/12] staging: lustre: Optimize error handling in class_register_type() Oleg Drokin <oleg.drokin@intel.com> - 2016-07-26 21:20 +0200
      Re: staging: lustre: Optimize error handling in class_register_type() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-07-26 22:20 +0200
  Re: [PATCH 03/12] staging: lustre: One function call less in class_register_type() after error detection Oleg Drokin <oleg.drokin@intel.com> - 2016-07-26 21:10 +0200
    Re: staging: lustre: One function call less in class_register_type()  after error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2016-07-26 22:00 +0200
      Re: staging: lustre: One function call less in class_register_type() after error detection Oleg Drokin <oleg.drokin@intel.com> - 2016-07-27 00:00 +0200
        Re: staging: lustre: One function call less in class_register_type()  after error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2016-07-28 08:00 +0200
          Re: [lustre-devel] staging: lustre: One function call less in class_register_type() after error detection Oleg Drokin <oleg.drokin@intel.com> - 2016-07-29 17:30 +0200
            Re: [lustre-devel] staging: lustre: One function call less in  class_register_type() after error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2016-07-30 08:30 +0200
  [PATCH 03/12] staging: lustre: One function call less in  class_register_type() after error detection SF Markus Elfring <elfring@users.sourceforge.net> - 2016-07-26 21:10 +0200
  [PATCH 12/12] staging: lustre: Delete an unnecessary variable  initialisation in mgc_process_recover_log() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-07-26 21:20 +0200
  [PATCH 11/12] staging: lustre: Move an assignment for the variable  "eof" in mgc_process_recover_log() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-07-26 21:20 +0200
  [PATCH 10/12] staging: lustre: Rename jump labels in  mgc_process_recover_log() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-07-26 21:20 +0200
  [PATCH 09/12] staging: lustre: Delete a check for the variable "req"  in mgc_process_recover_log() SF Markus Elfring <elfring@users.sourceforge.net> - 2016-07-26 21:20 +0200

csiph-web