qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH V11 13/17] block: dump to buffer for bdrv_snapsh


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH V11 13/17] block: dump to buffer for bdrv_snapshot_dump() and bdrv_image_info_dump()
Date: Wed, 10 Apr 2013 18:56:42 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux)

Stefan Hajnoczi <address@hidden> 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 :)



reply via email to

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