qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 3/6] block: qapi - move string allocation fro


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH v2 3/6] block: qapi - move string allocation from stack to the heap
Date: Thu, 22 Jan 2015 11:24:45 +0000
User-agent: Mutt/1.5.23 (2014-03-12)

On Tue, Jan 20, 2015 at 12:31:30PM -0500, Jeff Cody wrote:
> Rather than declaring 'backing_filename2' on the stack in
> bdrv_quiery_image_info(), dynamically allocate it on the heap.

s/quiery/query/

> 
> Signed-off-by: Jeff Cody <address@hidden>
> ---
>  block/qapi.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/block/qapi.c b/block/qapi.c
> index a6fd6f7..e51bade 100644
> --- a/block/qapi.c
> +++ b/block/qapi.c
> @@ -175,7 +175,7 @@ void bdrv_query_image_info(BlockDriverState *bs,
>  {
>      int64_t size;
>      const char *backing_filename;
> -    char backing_filename2[1024];
> +    char *backing_filename2 = NULL;
>      BlockDriverInfo bdi;
>      int ret;
>      Error *err = NULL;
> @@ -211,13 +211,14 @@ void bdrv_query_image_info(BlockDriverState *bs,
>  
>      backing_filename = bs->backing_file;
>      if (backing_filename[0] != '\0') {
> +        backing_filename2 = g_malloc0(1024);

backing_filename2 is only used inside the body of this if statement.
Please move the declaration in here to avoid initializing with NULL
(that value is never used but I had to check the surrounding code to
figure that out).

Attachment: pgp_vafVnR17i.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]