From: SF Markus Elfring <elfring@users.sourceforge.net>
To: lustre-devel@lists.lustre.org
Subject: [lustre-devel] [PATCH 1/3] staging: lustre: Delete unnecessary checks before two function calls
Date: Thu, 5 Nov 2015 13:15:52 +0100 [thread overview]
Message-ID: <563B4878.7000106@users.sourceforge.net> (raw)
In-Reply-To: <563B473C.5090508@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 5 Nov 2015 10:18:45 +0100
The functions kobject_put() and kset_unregister() test whether their
argument is NULL and then return immediately.
Thus the tests around their calls are 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 | 10 +++-------
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, 8 insertions(+), 17 deletions(-)
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
index ca11511..e67e84b 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
@@ -1062,13 +1062,9 @@ static int ldlm_cleanup(void)
if (ldlm_state->ldlm_cb_service != NULL)
ptlrpc_unregister_service(ldlm_state->ldlm_cb_service);
- if (ldlm_ns_kset)
- kset_unregister(ldlm_ns_kset);
- if (ldlm_svc_kset)
- kset_unregister(ldlm_svc_kset);
- if (ldlm_kobj)
- kobject_put(ldlm_kobj);
-
+ kset_unregister(ldlm_ns_kset);
+ kset_unregister(ldlm_svc_kset);
+ 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 635a93c..c3c8e8c 100644
--- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c
+++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
@@ -240,7 +240,7 @@ static int lmv_connect(const struct lu_env *env,
if (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;
@@ -646,8 +646,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 7abe484..910c62c 100644
--- a/drivers/staging/lustre/lustre/lov/lov_obd.c
+++ b/drivers/staging/lustre/lustre/lov/lov_obd.c
@@ -109,9 +109,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 6477aeb..a1cf8e1 100644
--- a/drivers/staging/lustre/lustre/obdclass/genops.c
+++ b/drivers/staging/lustre/lustre/obdclass/genops.c
@@ -216,8 +216,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);
@@ -244,8 +243,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.6.2
next prev parent reply other threads:[~2015-11-05 12:15 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <5307CAA2.8060406@users.sourceforge.net>
[not found] ` <alpine.DEB.2.02.1402212321410.2043@localhost6.localdomain6>
[not found] ` <530A086E.8010901@users.sourceforge.net>
[not found] ` <alpine.DEB.2.02.1402231635510.1985@localhost6.localdomain6>
[not found] ` <530A72AA.3000601@users.sourceforge.net>
[not found] ` <alpine.DEB.2.02.1402240658210.2090@localhost6.localdomain6>
[not found] ` <530B5FB6.6010207@users.sourceforge.net>
[not found] ` <alpine.DEB.2.10.1402241710370.2074@hadrien>
[not found] ` <530C5E18.1020800@users.sourceforge.net>
[not found] ` <alpine.DEB.2.10.1402251014170.2080@hadrien>
[not found] ` <530CD2C4.4050903@users.sourceforge.net>
[not found] ` <alpine.DEB.2.10.1402251840450.7035@hadrien>
[not found] ` <530CF8FF.8080600@users.sourceforge.net>
[not found] ` <alpine.DEB.2.02.1402252117150.2047@localhost6.localdomain6>
[not found] ` <530DD06F.4090703@users.sourceforge.net>
[not found] ` <alpine.DEB.2.02.1402262129250.2221@localhost6.localdomain6>
[not found] ` <5317A59D.4@users.sourceforge.net>
2015-11-05 12:10 ` [lustre-devel] [PATCH 0/3] staging: lustre: Deletion of some unnecessary checks SF Markus Elfring
2015-11-05 12:15 ` SF Markus Elfring [this message]
2015-11-05 12:57 ` [lustre-devel] [PATCH 1/3] staging: lustre: Delete unnecessary checks before two function calls Dan Carpenter
2015-11-05 12:18 ` [lustre-devel] [PATCH 2/3] staging: lustre: Delete an unnecessary variable initialisation in class_register_type() SF Markus Elfring
2015-11-05 12:57 ` Dan Carpenter
2015-11-05 12:20 ` [lustre-devel] [PATCH 3/3] staging: lustre: Less function calls in class_register_type() after error detection SF Markus Elfring
2015-11-25 16:39 ` Greg Kroah-Hartman
2015-11-26 7:08 ` SF Markus Elfring
2015-11-26 16:53 ` Greg Kroah-Hartman
2015-11-26 19:02 ` SF Markus Elfring
2015-11-26 20:01 ` Dan Carpenter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=563B4878.7000106@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=lustre-devel@lists.lustre.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).