From: John Snow <jsnow@redhat.com>
To: Jeff Cody <jcody@redhat.com>, qemu-devel@nongnu.org
Cc: kwolf@redhat.com, famz@redhat.com, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2 3/6] block: qapi - move string allocation from stack to the heap
Date: Tue, 20 Jan 2015 13:37:13 -0500 [thread overview]
Message-ID: <54BEA059.8040209@redhat.com> (raw)
In-Reply-To: <a4f5aa8f94a835092d1a95547e5b9a9be10aa70d.1421768887.git.jcody@redhat.com>
On 01/20/2015 12:31 PM, Jeff Cody wrote:
> Rather than declaring 'backing_filename2' on the stack in
> bdrv_quiery_image_info(), dynamically allocate it on the heap.
>
> Signed-off-by: Jeff Cody <jcody@redhat.com>
> ---
> 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);
> info->backing_filename = g_strdup(backing_filename);
> info->has_backing_filename = true;
> - bdrv_get_full_backing_filename(bs, backing_filename2,
> - sizeof(backing_filename2), &err);
> + bdrv_get_full_backing_filename(bs, backing_filename2, 1024, &err);
> if (err) {
> error_propagate(errp, err);
> qapi_free_ImageInfo(info);
> + g_free(backing_filename2);
> return;
> }
>
> @@ -231,6 +232,7 @@ void bdrv_query_image_info(BlockDriverState *bs,
> info->backing_filename_format = g_strdup(bs->backing_format);
> info->has_backing_filename_format = true;
> }
> + g_free(backing_filename2);
> }
>
> ret = bdrv_query_snapshot_info_list(bs, &info->snapshots, &err);
>
Reviewed-by: John Snow <jsnow@redhat.com>
next prev parent reply other threads:[~2015-01-20 18:37 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-20 17:31 [Qemu-devel] [PATCH v2 0/6] RESEND - Update filename string sizes in block layer Jeff Cody
2015-01-20 17:31 ` [Qemu-devel] [PATCH v2 1/6] block: vmdk - make ret variable usage clear Jeff Cody
2015-01-20 18:37 ` John Snow
2015-01-22 10:56 ` Stefan Hajnoczi
2015-01-20 17:31 ` [Qemu-devel] [PATCH v2 2/6] block: vmdk - move string allocations from stack to the heap Jeff Cody
2015-01-20 18:37 ` John Snow
2015-01-22 11:17 ` Stefan Hajnoczi
2015-01-22 11:23 ` Daniel P. Berrange
2015-01-20 17:31 ` [Qemu-devel] [PATCH v2 3/6] block: qapi - move string allocation " Jeff Cody
2015-01-20 18:37 ` John Snow [this message]
2015-01-22 11:24 ` Stefan Hajnoczi
2015-01-20 17:31 ` [Qemu-devel] [PATCH v2 4/6] block: " Jeff Cody
2015-01-20 18:37 ` John Snow
2015-01-22 11:37 ` Stefan Hajnoczi
2015-01-22 12:15 ` Jeff Cody
2015-01-20 17:31 ` [Qemu-devel] [PATCH v2 5/6] block: mirror - change string allocation to 2-bytes Jeff Cody
2015-01-20 18:37 ` John Snow
2015-01-22 11:41 ` Stefan Hajnoczi
2015-01-20 17:31 ` [Qemu-devel] [PATCH v2 6/6] block: update string sizes for filename, backing_file, exact_filename Jeff Cody
2015-01-20 18:37 ` John Snow
2015-01-22 11:46 ` Stefan Hajnoczi
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=54BEA059.8040209@redhat.com \
--to=jsnow@redhat.com \
--cc=famz@redhat.com \
--cc=jcody@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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 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.