qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] migration: don't use uninitialized variables


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH] migration: don't use uninitialized variables
Date: Fri, 19 Jul 2013 04:57:51 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7

On 07/18/2013 08:36 PM, Pawit Pornkitprasan wrote:
> The qmp_migrate method uses the 'blk' and 'inc' parameter without
> checking if they're valid or not (they may be uninitialized if
> command is received via QMP)
> 
> Signed-off-by: Pawit Pornkitprasan <address@hidden>
> ---
>  migration.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Eric Blake <address@hidden>

However, wouldn't it be nice if we improved the qapi generator to
guarantee a sane default value for optional parameters, even when
has_value is false?

> 
> diff --git a/migration.c b/migration.c
> index 9f5a423..f3d1ff7 100644
> --- a/migration.c
> +++ b/migration.c
> @@ -385,8 +385,8 @@ void qmp_migrate(const char *uri, bool has_blk, bool blk,
>      MigrationParams params;
>      const char *p;
>  
> -    params.blk = blk;
> -    params.shared = inc;
> +    params.blk = has_blk && blk;
> +    params.shared = has_inc && inc;
>  
>      if (s->state == MIG_STATE_ACTIVE) {
>          error_set(errp, QERR_MIGRATION_ACTIVE);
> 

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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