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

From: SF Markus Elfring
Date: Thu Dec 31 2015 - 15:26:55 EST


From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
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@xxxxxxxxxxxxxxxxxxxxx>
---
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@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/