U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/3] sf: ops: Squash the malloc+memset combo
Date: Fri, 17 Jan 2014 15:43:31 +0100	[thread overview]
Message-ID: <201401171543.31458.marex@denx.de> (raw)
In-Reply-To: <9e839652-bcb9-45d6-95c5-ebd5b2ec0998@AM1EHSMHS010.ehs.local>

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@xilinx.com>
> Cc: Marek Vasut <marex@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

  reply	other threads:[~2014-01-17 14:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-17 14:41 [U-Boot] [PATCH 1/3] sf: ops: Squash the malloc+memset combo Jagannadha Sutradharudu Teki
2014-01-17 14:43 ` Marek Vasut [this message]
2014-01-17 14:45   ` Jagan Teki

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=201401171543.31458.marex@denx.de \
    --to=marex@denx.de \
    --cc=u-boot@lists.denx.de \
    /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