[libvirt] [PATCH 4/4] cleanup: Change datatype of net->stp to boolean

Eric Blake eblake at redhat.com
Fri Apr 12 15:17:38 UTC 2013


On 04/12/2013 08:38 AM, Laine Stump wrote:
> On 04/12/2013 05:21 AM, Osier Yang wrote:
>> ---

> Your conversion is fine, but this does highlight that the code here
> interprets *everything* except "off" as "on" (including "OFF", "no",
> "Off", "0").
> 
> There are actually many similar instances in the parser code. Should we
> continue to be so silently strict? Or complain any time the string isn't
> *exactly* "on" or "off"? Or make it extremely tolerant about what is
> entered (0, off, Off, no, false all mean the same thing)?

It also begs the question - is our .rng schema capable of parsing the
same set of options as our C code accepts, and flagging the typos?

> 
> Is it worth making a helper function that takes a const char * and
> returns true/false according to whatever rules we decide, then use that
> everywhere there is an on/off (or yes/no) attribute?

Yes, I think having a common parse helper function, as well as using a
common <define> throughout the RNG schema that accepts the same things
as the C code, would go a long way to making this friendlier to users.
I also think that adding a way to canonicalize an XML snippet, including
the option to reject it if it fails the RNG schema, would be a helpful
addition to the API (we've mentioned the idea in the past, but it has
not been implemented yet).

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130412/ec439e84/attachment-0001.sig>


More information about the libvir-list mailing list