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 1/3] mtd-rfd_ftl: Replace a variable initialisation by assignments in move_block_contents()
Date: Thu, 31 Dec 2015 21:25:57 +0100 [thread overview]
Message-ID: <56858F55.7040604@users.sourceforge.net> (raw)
In-Reply-To: <56858E3A.7000706@users.sourceforge.net>
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 31 Dec 2015 20:34:51 +0100
Replace an explicit initialisation for the variable "rc" at the beginning
by assignments that will only be performed if a memory allocation failed.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/mtd/rfd_ftl.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/mtd/rfd_ftl.c b/drivers/mtd/rfd_ftl.c
index d1cbf26..2927e1b 100644
--- a/drivers/mtd/rfd_ftl.c
+++ b/drivers/mtd/rfd_ftl.c
@@ -359,17 +359,21 @@ static int move_block_contents(struct partition *part, int block_no, u_long *old
void *sector_data;
u16 *map;
size_t retlen;
- int i, rc = -ENOMEM;
+ int i, rc;
part->is_reclaiming = 1;
sector_data = kmalloc(SECTOR_SIZE, GFP_KERNEL);
- if (!sector_data)
+ if (!sector_data) {
+ rc = -ENOMEM;
goto err3;
+ }
map = kmalloc(part->header_size, GFP_KERNEL);
- if (!map)
+ if (!map) {
+ rc = -ENOMEM;
goto err2;
+ }
rc = mtd_read(part->mbd.mtd, part->blocks[block_no].offset,
part->header_size, &retlen, (u_char *)map);
--
2.6.3
next prev parent reply other threads:[~2015-12-31 20:26 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 ` SF Markus Elfring [this message]
2015-12-31 20:26 ` [PATCH 2/3] mtd-rfd_ftl: Refactoring for move_block_contents() SF Markus Elfring
2015-12-31 20:27 ` [PATCH 3/3] mtd-rfd_ftl: Refactoring for erase_block() SF Markus Elfring
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=56858F55.7040604@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).