[U-Boot] [PATCH 1/3] sf: ops: Squash the malloc+memset combo
Marek Vasut
marex at denx.de
Fri Jan 17 15:43:31 CET 2014
On Friday, January 17, 2014 at 03:41:45 PM, Jagannadha Sutradharudu Teki wrote:
> Squash the malloc()+memset() combo in favor of calloc().
>
> Signed-off-by: Jagannadha Sutradharudu Teki <jaganna at xilinx.com>
> Cc: Marek Vasut <marex at denx.de>
> ---
> drivers/mtd/spi/sf_ops.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/mtd/spi/sf_ops.c b/drivers/mtd/spi/sf_ops.c
> index 1f1bb36..9650486 100644
> --- a/drivers/mtd/spi/sf_ops.c
> +++ b/drivers/mtd/spi/sf_ops.c
> @@ -381,8 +381,7 @@ int spi_flash_cmd_read_ops(struct spi_flash *flash, u32
> offset, }
>
> cmdsz = SPI_FLASH_CMD_LEN + flash->dummy_byte;
> - cmd = malloc(cmdsz);
> - memset(cmd, 0, cmdsz);
> + cmd = calloc(1, cmdsz);
>
> cmd[0] = flash->read_cmd;
What exactly will happen here when calloc() fails ? :-)
(that means, please check the return value ;-) )
> while (len) {
Best regards,
Marek Vasut
More information about the U-Boot
mailing list