[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] qemu-config: Accept empty option values
From: |
Eduardo Habkost |
Subject: |
Re: [Qemu-devel] [PATCH] qemu-config: Accept empty option values |
Date: |
Thu, 9 Apr 2015 15:50:59 -0300 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
On Thu, Apr 09, 2015 at 02:11:11PM +0200, Paolo Bonzini wrote:
> On 08/04/2015 20:16, Eduardo Habkost wrote:
> > Currently it is impossible to set an option in a config file to an empty
> > string, because the parser matches only lines containing non-empty
> > strings between double-quotes.
> >
> > As sscanf() "[" conversion specifier only matches non-empty strings, add
> > a special case for empty strings.
> >
> > Signed-off-by: Eduardo Habkost <address@hidden>
> > ---
> > util/qemu-config.c | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/util/qemu-config.c b/util/qemu-config.c
> > index 2d32ce7..9f9577d 100644
> > --- a/util/qemu-config.c
> > +++ b/util/qemu-config.c
> > @@ -413,7 +413,8 @@ int qemu_config_parse(FILE *fp, QemuOptsList **lists,
> > const char *fname)
> > opts = qemu_opts_create(list, NULL, 0, &error_abort);
> > continue;
> > }
> > - if (sscanf(line, " %63s = \"%1023[^\"]\"", arg, value) == 2) {
> > + if (sscanf(line, " %63s = \"%1023[^\"]\"", arg, value) == 2 ||
> > + (value[0] = '\0', sscanf(line, " %63s = \"\"", arg) == 1)) {
> > /* arg = value */
> > if (opts == NULL) {
> > error_report("no group defined");
> >
>
> Acked-by: Paolo Bonzini <address@hidden>
Thanks! Whose tree this should go through?
--
Eduardo