[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).
pgp_vafVnR17i.pgp
Description: PGP signature
- [Qemu-devel] [PATCH v2 0/6] RESEND - Update filename string sizes in block layer, Jeff Cody, 2015/01/20
- [Qemu-devel] [PATCH v2 2/6] block: vmdk - move string allocations from stack to the heap, Jeff Cody, 2015/01/20
- [Qemu-devel] [PATCH v2 3/6] block: qapi - move string allocation from stack to the heap, Jeff Cody, 2015/01/20
- [Qemu-devel] [PATCH v2 4/6] block: move string allocation from stack to the heap, Jeff Cody, 2015/01/20
- [Qemu-devel] [PATCH v2 5/6] block: mirror - change string allocation to 2-bytes, Jeff Cody, 2015/01/20
- [Qemu-devel] [PATCH v2 1/6] block: vmdk - make ret variable usage clear, Jeff Cody, 2015/01/20