qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [v19 01/25] add def_value_str to QemuOptDesc


From: Kevin Wolf
Subject: Re: [Qemu-devel] [v19 01/25] add def_value_str to QemuOptDesc
Date: Wed, 22 Jan 2014 14:25:54 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

Am 20.01.2014 um 15:19 hat Chunyan Liu geschrieben:
> Add def_value_str (default value) to QemuOptDesc, to replace function of the
> default value in QEMUOptionParameter. And improved related functions.
>  
> Signed-off-by: Dong Xu Wang <address@hidden>
> Signed-off-by: Chunyan Liu <address@hidden>

It would be worth mentioning that qemu_opts_print() is unused, so
changing the prototype and behaviour is fine.

> -int qemu_opts_print(QemuOpts *opts, void *dummy)
> +void qemu_opts_print(QemuOpts *opts)
>  {
>      QemuOpt *opt;
> +    QemuOptDesc *desc = opts->list->desc;
>  
> -    fprintf(stderr, "%s: %s:", opts->list->name,
> -            opts->id ? opts->id : "<noid>");
> -    QTAILQ_FOREACH(opt, &opts->head, next) {
> -        fprintf(stderr, " %s=\"%s\"", opt->name, opt->str);
> +    if (desc[0].name == NULL) {

I think 'if (opts_accepts_any(opts))' would be more readable.

> +        QTAILQ_FOREACH(opt, &opts->head, next) {
> +            printf("%s=\"%s\" ", opt->name, opt->str);
> +        }
> +        return;
> +    }
> +    for (; desc && desc->name; desc++) {
> +        const char *value = desc->def_value_str;
> +        QemuOpt *opt;
> +
> +        opt = qemu_opt_find(opts, desc->name);
> +        if (opt) {
> +            value = opt->str;
> +        }
> +
> +        if (!value) {
> +            continue;
> +        }
> +
> +        if (desc->type == QEMU_OPT_STRING) {
> +            printf("%s='%s' ", desc->name, value);
> +        } else if (desc->type == QEMU_OPT_SIZE && opt) {
> +            printf("%s=%" PRIu64 " ", desc->name, opt->value.uint);

This is so that a value like '64k' gets expanded to '65536'? Perhaps add
a comment?

> +        } else {
> +            printf("%s=%s ", desc->name, value);
> +        }
>      }
> -    fprintf(stderr, "\n");
> -    return 0;
>  }

Kevin



reply via email to

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