All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/3] sf: ops: Squash the malloc+memset combo
@ 2014-01-17 14:41 Jagannadha Sutradharudu Teki
  2014-01-17 14:43 ` Marek Vasut
  0 siblings, 1 reply; 3+ messages in thread
From: Jagannadha Sutradharudu Teki @ 2014-01-17 14:41 UTC (permalink / raw)
  To: u-boot

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;
 	while (len) {
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH 1/3] sf: ops: Squash the malloc+memset combo
  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
  2014-01-17 14:45   ` Jagan Teki
  0 siblings, 1 reply; 3+ messages in thread
From: Marek Vasut @ 2014-01-17 14:43 UTC (permalink / raw)
  To: u-boot

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH 1/3] sf: ops: Squash the malloc+memset combo
  2014-01-17 14:43 ` Marek Vasut
@ 2014-01-17 14:45   ` Jagan Teki
  0 siblings, 0 replies; 3+ messages in thread
From: Jagan Teki @ 2014-01-17 14:45 UTC (permalink / raw)
  To: u-boot

On Fri, Jan 17, 2014 at 8:13 PM, Marek Vasut <marex@denx.de> wrote:
> 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 ;-) )
>
Yes - will take care that. thanks!

-- 
Jagan.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-01-17 14:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2014-01-17 14:45   ` Jagan Teki

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.