On Fri, Apr 16, 2021 at 14:21:00 +0200, Tim Wiederhake wrote: > Signed-off-by: Tim Wiederhake <twiederh@xxxxxxxxxx> > --- > src/conf/device_conf.c | 26 ++++++-------------------- > 1 file changed, 6 insertions(+), 20 deletions(-) > > diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c > index 1ce31e9234..a2893fec6f 100644 > --- a/src/conf/device_conf.c > +++ b/src/conf/device_conf.c > @@ -468,28 +468,14 @@ int > virInterfaceLinkParseXML(xmlNodePtr node, > virNetDevIfLink *lnk) > { > - int state; > - > - g_autofree char *stateStr = virXMLPropString(node, "state"); > - g_autofree char *speedStr = virXMLPropString(node, "speed"); > - > - if (stateStr) { > - if ((state = virNetDevIfStateTypeFromString(stateStr)) < 0) { > - virReportError(VIR_ERR_XML_ERROR, > - _("unknown link state: %s"), > - stateStr); > - return -1; > - } > - lnk->state = state; > - } > + if (virXMLPropEnum(node, "state", virNetDevIfStateTypeFromString, > + VIR_XML_PROP_OPTIONAL, &lnk->state) < 0) > + return -1; > > - if (speedStr && > - virStrToLong_ui(speedStr, NULL, 10, &lnk->speed) < 0) { This was using virStrToLong_ui which has the 'wrap-around' anti feature. > - virReportError(VIR_ERR_XML_ERROR, > - _("Unable to parse link speed: %s"), > - speedStr); > + if (virXMLPropUInt(node, "speed", 10, VIR_XML_PROP_OPTIONAL, > + &lnk->speed) < 0) Strictifying the parser must be sufficiently justified in the commit message. > return -1; > - } > + > return 0; > } > > -- > 2.26.2 >