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


Groups > linux.kernel > #1299773

[PATCH 1/3] mtd-rfd_ftl: Replace a variable initialisation by assignments in move_block_contents()

From SF Markus Elfring <elfring@users.sourceforge.net>
Newsgroups linux.kernel
Subject [PATCH 1/3] mtd-rfd_ftl: Replace a variable initialisation by assignments in move_block_contents()
Date 2015-12-31 21:30 +0100
Message-ID <qLS1c-Fs-11@gated-at.bofh.it> (permalink)
References <qEuGl-43C-5@gated-at.bofh.it> <qLS1c-Fs-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

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


Thread

[PATCH 1/3] mtd-rfd_ftl: Replace a variable initialisation by  assignments in move_block_contents() SF Markus Elfring <elfring@users.sourceforge.net> - 2015-12-31 21:30 +0100

csiph-web