qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH V4 06/10] create new function: qemu_opt_set_numb


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH V4 06/10] create new function: qemu_opt_set_number
Date: Fri, 26 Oct 2012 11:02:57 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

On Thu, Oct 25, 2012 at 08:57:24PM +0800, Dong Xu Wang wrote:
> diff --git a/qemu-option.c b/qemu-option.c
> index d7d5ea9..eeb2c9c 100644
> --- a/qemu-option.c
> +++ b/qemu-option.c
> @@ -695,6 +695,30 @@ int qemu_opt_set_bool(QemuOpts *opts, const char *name, 
> bool val)
>      return 0;
>  }
>  
> +int qemu_opt_set_number(QemuOpts *opts, const char *name, int64_t val)
> +{
> +    char buffer[1024];
> +    QemuOpt *opt;
> +    const QemuOptDesc *desc = opts->list->desc;
> +
> +    snprintf(buffer, sizeof(buffer), "%" PRId64, val);

g_strdup_printf() is a nice replacement for fixed-size buffer +
snprintf() + g_strdup():

http://developer.gnome.org/glib/2.28/glib-String-Utility-Functions.html#g-strdup-printf

Stefan



reply via email to

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