[libvirt] [PATCH 1/6] Allow network model to contain "-"

Michael Ellerman michael at ellerman.id.au
Sun Dec 11 23:54:01 UTC 2011


On Fri, 2011-12-09 at 12:34 -0700, Eric Blake wrote:
> On 12/08/2011 05:38 PM, Eric Blake wrote:
> >>          int i;
> >>          for (i = 0 ; i < strlen(model) ; i++) {
> 
> Hmm - an O(n) function call on an O(n) loop, for a quadratic action (of
> course, it's in the noise, since the user's model name is likely short).
>  But we can do better with a more efficient search for bogus bytes
> (strspn is O(n), if implemented well in libc).
> 
> >> -            int char_ok = c_isalnum(model[i]) || model[i] == '_';
> >> -            if (!char_ok) {
> >> +            if (!c_isalnum(model[i]) && model[i] != '_' && model[i] != '-') {
> > 
> > I'm not sure if we need to tweak our RNG grammar to also allow this in
> > the XML validation.  I'll check that out tomorrow, when I get around to
> > applying this one and reviewing the rest of the series.
> 
> It turns out the XML didn't do any validation at all.  Here's what I
> came up with - tightening the RNG and relaxing the domain_conf code, so
> that they now match.  Since the concept is the same as yours, I went
> ahead and pushed it, but I claimed authorship on this one, since I
> practically rewrote it.

Yep fair enough. Your new version is much nicer, looks good.

cheers

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20111212/74725bdf/attachment-0001.sig>


More information about the libvir-list mailing list