mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
virInterfaceDefParseMtu: Use virXPathUInt instead of virXPathULong
Use the proper convertor function and refactor error reporting. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
367fdfbff8
commit
b8e415b467
@ -113,17 +113,15 @@ static int
|
||||
virInterfaceDefParseMtu(virInterfaceDef *def,
|
||||
xmlXPathContextPtr ctxt)
|
||||
{
|
||||
unsigned long mtu;
|
||||
int ret;
|
||||
|
||||
ret = virXPathULong("string(./mtu/@size)", ctxt, &mtu);
|
||||
if ((ret == -2) || ((ret == 0) && (mtu > 100000))) {
|
||||
virReportError(VIR_ERR_XML_ERROR,
|
||||
"%s", _("interface mtu value is improper"));
|
||||
if (virXPathUInt("string(./mtu/@size)", ctxt, &def->mtu) == -2)
|
||||
return -1;
|
||||
|
||||
if (def->mtu > 100000) {
|
||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||
_("value of the 'size' attribute of 'mtu' element must be at most 100000"));
|
||||
return -1;
|
||||
} else if (ret == 0) {
|
||||
def->mtu = (unsigned int) mtu;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user