[libvirt] [PATCH] nwfilter: Some fixes to XML parser
Stefan Berger
stefanb at us.ibm.com
Thu Apr 1 18:10:50 UTC 2010
Eric Blake <eblake at redhat.com> wrote on 04/01/2010 01:20:30 PM:
>
> On 03/31/2010 02:45 PM, Stefan Berger wrote:
> > @@ -433,9 +430,10 @@ macProtocolIDFormatter(virBufferPtr buf,
> > nwf->p.ethHdrFilter.dataProtocolID.u.u16,
> > &str)) {
> > virBufferVSprintf(buf, "%s", str);
> > - return 1;
> > + } else {
> > + virBufferVSprintf(buf, "%d",
> nwf->p.ethHdrFilter.dataProtocolID.u.u16);
>
> This would look a bit better as %u than %d, to match the fact that we
> know it is unsigned, but at least I don't see any problems with sign
> extension biting us if we leave the line alone.
>
> > + if (virStrToLong_i(prop, NULL, 10,
> &int_val) == 0) {
> > + if (int_val >= 0 && int_val <= 32) {
>
> Is it any more efficient to use virStrToLong_ui, so that you can drop
> the int_val>=0 half of the test by virtue of the fact that you parsed an
> unsigned int to begin with?
Well, I could introduce a uint_val variable. I actually had tried that _ui
function yesterday but then the signed problem came up with the int_val
and thought that this probably boils down to 2 more assembly instructions
and left it as it is... Also it's not in a critical path where this test
was going to be done permanently. But yes, we can fix it along with the
strcpn() = strlen() I added...
Stefan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20100401/bbe6083d/attachment-0001.htm>
More information about the libvir-list
mailing list