linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Julia Lawall <Julia.Lawall@lip6.fr>
To: Oleg Drokin <oleg.drokin@intel.com>
Cc: kernel-janitors@vger.kernel.org,
	Andreas Dilger <andreas.dilger@intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	HPDD-discuss@ml01.01.org, devel@driverdev.osuosl.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 12/20] staging: lustre: obdclass: genops: remove unneeded null test before free
Date: Fri,  1 May 2015 21:37:55 +0200	[thread overview]
Message-ID: <1430509086-22132-10-git-send-email-Julia.Lawall@lip6.fr> (raw)
In-Reply-To: <1430509086-22132-1-git-send-email-Julia.Lawall@lip6.fr>

Kfree can cope with a null argument, so drop null tests.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@ expression ptr; @@

- if (ptr != NULL)
  kfree(ptr);
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/staging/lustre/lustre/obdclass/genops.c |   15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
index a107aea..37d6aef 100644
--- a/drivers/staging/lustre/lustre/obdclass/genops.c
+++ b/drivers/staging/lustre/lustre/obdclass/genops.c
@@ -213,12 +213,9 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
 	return 0;
 
  failed:
-	if (type->typ_name != NULL)
-		kfree(type->typ_name);
-	if (type->typ_md_ops != NULL)
-		kfree(type->typ_md_ops);
-	if (type->typ_dt_ops != NULL)
-		kfree(type->typ_dt_ops);
+	kfree(type->typ_name);
+	kfree(type->typ_md_ops);
+	kfree(type->typ_dt_ops);
 	kfree(type);
 	return rc;
 }
@@ -253,10 +250,8 @@ int class_unregister_type(const char *name)
 	list_del(&type->typ_chain);
 	spin_unlock(&obd_types_lock);
 	kfree(type->typ_name);
-	if (type->typ_dt_ops != NULL)
-		kfree(type->typ_dt_ops);
-	if (type->typ_md_ops != NULL)
-		kfree(type->typ_md_ops);
+	kfree(type->typ_dt_ops);
+	kfree(type->typ_md_ops);
 	kfree(type);
 	return 0;
 } /* class_unregister_type */


  parent reply	other threads:[~2015-05-01 19:50 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-01 19:37 [PATCH 0/20] remove unneeded null test before free Julia Lawall
2015-05-01 19:37 ` [PATCH 20/20] staging: lustre: ptlrpc: service: " Julia Lawall
2015-05-01 19:37 ` [PATCH 19/20] staging: lustre: ptlrpc: sec_plain: " Julia Lawall
2015-05-02  9:14   ` walter harms
2015-05-01 19:37 ` [PATCH 18/20] Staging: lustre: ptlrpc: lproc_ptlrpc: " Julia Lawall
2015-05-01 19:37 ` [PATCH 17/20] Staging: lustre: osc: " Julia Lawall
2015-05-01 19:37 ` [PATCH 16/20] staging: lustre: obdecho: " Julia Lawall
2015-05-01 19:37 ` [PATCH 15/20] staging: lustre: obdclass: obd_mount: " Julia Lawall
2015-05-01 19:37 ` [PATCH 14/20] staging: lustre: obdclass: obd_config: " Julia Lawall
2015-05-01 19:37 ` [PATCH 13/20] staging: lustre: obdclass: llog: " Julia Lawall
2015-05-01 19:37 ` Julia Lawall [this message]
2015-05-01 19:37 ` [PATCH 11/20] staging: lustre: mdc: " Julia Lawall
2015-05-01 19:37 ` [PATCH 10/20] staging: lustre: lov: lov_dev: " Julia Lawall
2015-05-01 19:37 ` [PATCH 9/20] staging: lustre: lmv: " Julia Lawall
2015-05-01 19:37 ` [PATCH 8/20] staging: lustre: llite: statahead: " Julia Lawall
2015-05-01 19:38 ` [PATCH 7/20] Staging: lustre: llite: llite_lib: " Julia Lawall
2015-05-01 19:38 ` [PATCH 6/20] Staging: lustre: llite: file: " Julia Lawall
2015-05-01 19:38 ` [PATCH 5/20] Staging: lustre: llite: dir: " Julia Lawall
2015-05-01 19:38 ` [PATCH 4/20] staging: lustre: libcfs: linux: " Julia Lawall
2015-05-01 19:38 ` [PATCH 3/20] staging: lustre: ldlm: ldlm_resource: " Julia Lawall
2015-05-01 19:38 ` [PATCH 2/20] staging: lustre: ldlm: ldlm_lock: " Julia Lawall
2015-05-01 19:38 ` [PATCH 1/20] staging: lustre: ldlm: ldlm_lib: " Julia Lawall
2015-05-02 20:55   ` 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=1430509086-22132-10-git-send-email-Julia.Lawall@lip6.fr \
    --to=julia.lawall@lip6.fr \
    --cc=HPDD-discuss@ml01.01.org \
    --cc=andreas.dilger@intel.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg.drokin@intel.com \
    /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).