linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: linux-mtd@lists.infradead.org,
	Brian Norris <computersforpeace@gmail.com>,
	David Woodhouse <dwmw2@infradead.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	kernel-janitors@vger.kernel.org,
	Julia Lawall <julia.lawall@lip6.fr>
Subject: [PATCH 3/3] mtd-rfd_ftl: Refactoring for erase_block()
Date: Thu, 31 Dec 2015 21:27:40 +0100	[thread overview]
Message-ID: <56858FBC.70103@users.sourceforge.net> (raw)
In-Reply-To: <56858E3A.7000706@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 31 Dec 2015 21:06:27 +0100

This issue was detected by using the Coccinelle software.

* Return directly if a memory allocation failed.

* Drop the explicit initialisation for the variable "rc"
  at the beginning then.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/mtd/rfd_ftl.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/rfd_ftl.c b/drivers/mtd/rfd_ftl.c
index 9b59423..8379447 100644
--- a/drivers/mtd/rfd_ftl.c
+++ b/drivers/mtd/rfd_ftl.c
@@ -326,11 +326,11 @@ static void erase_callback(struct erase_info *erase)
 static int erase_block(struct partition *part, int block)
 {
 	struct erase_info *erase;
-	int rc = -ENOMEM;
+	int rc;
 
 	erase = kmalloc(sizeof(struct erase_info), GFP_KERNEL);
 	if (!erase)
-		goto err;
+		return -ENOMEM;
 
 	erase->mtd = part->mbd.mtd;
 	erase->callback = erase_callback;
@@ -349,8 +349,6 @@ static int erase_block(struct partition *part, int block)
 				(unsigned long long)erase->len, part->mbd.mtd->name);
 		kfree(erase);
 	}
-
-err:
 	return rc;
 }
 
-- 
2.6.3

  parent reply	other threads:[~2015-12-31 20:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <566ABCD9.1060404@users.sourceforge.net>
2015-12-31 20:21 ` [PATCH 0/3] mtd-rfd_ftl: Fine-tuning for two function implementations SF Markus Elfring
2015-12-31 20:25   ` [PATCH 1/3] mtd-rfd_ftl: Replace a variable initialisation by assignments in move_block_contents() SF Markus Elfring
2015-12-31 20:26   ` [PATCH 2/3] mtd-rfd_ftl: Refactoring for move_block_contents() SF Markus Elfring
2015-12-31 20:27   ` SF Markus Elfring [this message]
2016-01-05  0:13   ` [PATCH 0/3] mtd-rfd_ftl: Fine-tuning for two function implementations Brian Norris

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=56858FBC.70103@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --cc=computersforpeace@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=julia.lawall@lip6.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.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).