All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Jackson <Ian.Jackson@eu.citrix.com>
To: Gianni Tedesco <gianni.tedesco@citrix.com>
Cc: "xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: Re: [PATCH] libxl: new xlu_disk_parse function
Date: Thu, 31 Mar 2011 18:30:19 +0100	[thread overview]
Message-ID: <19860.47659.19132.816771@mariner.uk.xensource.com> (raw)
In-Reply-To: <1301333477.1691.7.camel@qabil.uk.xensource.com>

Gianni Tedesco writes ("Re: [Xen-devel] [PATCH] libxl: new xlu_disk_parse function"):
> On Thu, 2011-03-24 at 17:49 +0000, Ian Jackson wrote:
> > +       return;
> 
>        case 1: ??

Deliberately omitted.

> > +    case 2:
> > +    case 3:
> > +    case 4:
> > +       break;
> 
> Or does it belong here? In which case aborting on a parse error is bad
> juju.
>        case 1:
> > +    default:
> > +       abort();

I could add it there for clarity.  The regexp will always match
capturing with 2, 3 or 4 parens.  None of the other errors from
dfa_exec are applicable.  So anything other than 2,3,4 or "did not
match" is due to a bug in the code, not merely bogus input.  Perhaps
this should be mentioned in a comment.

> Hmm, I'm not sure this is nicer than the code it's replacing, it's
> certainly a lot longer. I don't like the idea of it being full of things
> comparing for ",w" or ":cdrom" etc, rather than tokenising it fully and
> evaluating what the tokens are separately.

Perhaps you're right.  Unfortunately the nasty multi-level nature of
this parsing problem makes this a bit awkward.

But I think I can remove the delimiters into the regexp which perhaps
will help.

> > +raw:           { DSET(format,FORMAT,RAW); }
> > +qcow:          { DSET(format,FORMAT,QCOW); }
> > +qcow2:         { DSET(format,FORMAT,QCOW2); }
> > +vhd:           { DSET(format,FORMAT,QCOW2); }
> > +
> > +phy:           { DSET(format,FORMAT,RAW); DSET(backend,BACKEND,PHY); }
> > +file:          { DSET(format,FORMAT,RAW); DSET(backend,BACKEND,TAP); }
> > +tapdisk:|tap2?:        { DSET(backend,BACKEND,TAP); }
> > +aio:           { }
> > +ioemu:         { }
> 
> This bit is quite nice though. We could probably just tidy up the
> existing parser using arrays of values and things rather than a lot of
> if/else statements though.

I wanted to avoid parsing with pointer arithmetic, which is very easy
to write bugs in - particularly when new features are added.

Ian.

  parent reply	other threads:[~2011-03-31 17:30 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-24 17:49 [PATCH] libxl: move TOSTRING to libxl_internal.h Ian Jackson
2011-03-24 17:49 ` [PATCH] libxl: new xlu_disk_parse function Ian Jackson
2011-03-24 17:49   ` [PATCH] xl: replace config file disk spec parser with call to xlu_disk_parse Ian Jackson
2011-03-24 17:49     ` [PATCH] xl: replace block-attach disk config parser with call to xlu_parse_disk Ian Jackson
2011-03-28 17:31   ` [PATCH] libxl: new xlu_disk_parse function Gianni Tedesco
2011-03-28 18:13     ` Stefano Stabellini
2011-03-29  9:10       ` Ian Campbell
2011-03-31 17:33       ` Ian Jackson
2011-04-01 15:28         ` Stefano Stabellini
2011-03-31 17:30     ` Ian Jackson [this message]
2011-04-02  8:51       ` Ian Campbell
2011-04-04 11:29       ` Stefano Stabellini
2011-04-14  7:20       ` Gianni Tedesco

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19860.47659.19132.816771@mariner.uk.xensource.com \
    --to=ian.jackson@eu.citrix.com \
    --cc=gianni.tedesco@citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.