qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v3] i386: Fix GCC warning with snprintf when HAX is enabled


From: Paolo Bonzini
Subject: Re: [PATCH v3] i386: Fix GCC warning with snprintf when HAX is enabled
Date: Mon, 2 Mar 2020 01:05:37 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1

On 01/03/20 20:21, Julio Faracco wrote:
> +    assert(vm_id < 0);
> +
> +    if (snprintf(name, sizeof HAX_VM_DEVFS, "/dev/hax_vm/vm%02d",
> +                 vm_id) < 0)
> +        return NULL;
> +
>      return name;
>  }
>  
> @@ -140,8 +145,12 @@ static char *hax_vcpu_devfs_string(int vm_id, int 
> vcpu_id)
>          return NULL;
>      }
>  
> -    snprintf(name, sizeof HAX_VCPU_DEVFS, "/dev/hax_vm%02d/vcpu%02d",
> -             vm_id, vcpu_id);
> +    assert(vm_id < 0 || vcpu_id < 0);
> +
> +    if (snprintf(name, sizeof HAX_VCPU_DEVFS, "/dev/hax_vm%02d/vcpu%02d",
> +                 vm_id, vcpu_id) < 0)


Can you just replace snprintf with g_strdup_printf instead?  Then you
can also remove MAX_VM_ID and MAX_VCPU_ID.

Paolo




reply via email to

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