From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:60352) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPyLA-000775-WE for qemu-devel@nongnu.org; Wed, 10 Apr 2013 12:57:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UPyL9-0004wU-SJ for qemu-devel@nongnu.org; Wed, 10 Apr 2013 12:57:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:26814) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPyL9-0004wI-Lq for qemu-devel@nongnu.org; Wed, 10 Apr 2013 12:57:43 -0400 From: Markus Armbruster References: <1364903250-10429-1-git-send-email-xiawenc@linux.vnet.ibm.com> <1364903250-10429-14-git-send-email-xiawenc@linux.vnet.ibm.com> <20130408133637.GC4429@stefanha-thinkpad.redhat.com> Date: Wed, 10 Apr 2013 18:56:42 +0200 In-Reply-To: <20130408133637.GC4429@stefanha-thinkpad.redhat.com> (Stefan Hajnoczi's message of "Mon, 8 Apr 2013 15:36:37 +0200") Message-ID: <87obdmtjcl.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH V11 13/17] block: dump to buffer for bdrv_snapshot_dump() and bdrv_image_info_dump() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: kwolf@redhat.com, pbonzini@redhat.com, lcapitulino@redhat.com, Wenchao Xia , qemu-devel@nongnu.org Stefan Hajnoczi writes: > On Tue, Apr 02, 2013 at 07:47:26PM +0800, Wenchao Xia wrote: >> diff --git a/qemu-img.c b/qemu-img.c >> index 5b229a9..032f68c 100644 >> --- a/qemu-img.c >> +++ b/qemu-img.c >> @@ -1558,18 +1558,24 @@ static void dump_snapshots(BlockDriverState *bs) >> { >> QEMUSnapshotInfo *sn_tab, *sn; >> int nb_sns, i; >> - char buf[256]; >> + GString *buf = g_string_new(NULL); >> >> nb_sns = bdrv_snapshot_list(bs, &sn_tab); >> if (nb_sns <= 0) >> return; > > Leaks buf. Trivially avoided my moving the initialization behind the return. >> diff --git a/savevm.c b/savevm.c >> index e4e0008..ce0bbe1 100644 >> --- a/savevm.c >> +++ b/savevm.c >> @@ -2466,7 +2466,7 @@ void do_info_snapshots(Monitor *mon, const QDict *qdict) >> int nb_sns, i, ret, available; >> int total; >> int *available_snapshots; >> - char buf[256]; >> + GString *buf = NULL; >> >> bs = bdrv_snapshots(); >> if (!bs) { >> @@ -2509,11 +2509,16 @@ void do_info_snapshots(Monitor *mon, const >> QDict *qdict) >> } >> >> if (total > 0) { > > Please declare buf here since it is only used in this scope. Matter of taste. I'd keep it where it is :)