[U-Boot] [PATCH] sf: Squash the malloc+memset combo

Marek Vasut marex at denx.de
Wed Jan 15 15:17:54 CET 2014


Squash the malloc()+memset() combo in favor of calloc().

Signed-off-by: Marek Vasut <marex at denx.de>
Cc: Jagannadha Sutradharudu Teki <jaganna at xilinx.com>
---
 drivers/mtd/spi/sf_probe.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

NOTE: compile-tested only.

diff --git a/drivers/mtd/spi/sf_probe.c b/drivers/mtd/spi/sf_probe.c
index bc3cf6c..e84ab13 100644
--- a/drivers/mtd/spi/sf_probe.c
+++ b/drivers/mtd/spi/sf_probe.c
@@ -123,12 +123,11 @@ static struct spi_flash *spi_flash_validate_params(struct spi_slave *spi,
 		return NULL;
 	}
 
-	flash = malloc(sizeof(*flash));
+	flash = calloc(1, sizeof(*flash));
 	if (!flash) {
 		debug("SF: Failed to allocate spi_flash\n");
 		return NULL;
 	}
-	memset(flash, '\0', sizeof(*flash));
 
 	/* Assign spi data */
 	flash->spi = spi;
-- 
1.8.5.2



More information about the U-Boot mailing list