1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

virDomainRedirFilterUSBDevDefParseXML: Use g_auto*

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Tim Wiederhake 2021-05-04 16:02:26 +02:00 committed by Michal Privoznik
parent 54fb0b9e95
commit 7bc4f10807

View File

@ -14505,7 +14505,7 @@ virDomainRedirFilterUSBVersionHelper(const char *version,
static virDomainRedirFilterUSBDevDef * static virDomainRedirFilterUSBDevDef *
virDomainRedirFilterUSBDevDefParseXML(xmlNodePtr node) virDomainRedirFilterUSBDevDefParseXML(xmlNodePtr node)
{ {
virDomainRedirFilterUSBDevDef *def; g_autofree virDomainRedirFilterUSBDevDef *def = NULL;
g_autofree char *version = NULL; g_autofree char *version = NULL;
virTristateBool allow; virTristateBool allow;
@ -14513,42 +14513,38 @@ virDomainRedirFilterUSBDevDefParseXML(xmlNodePtr node)
def->usbClass = -1; def->usbClass = -1;
if (virXMLPropInt(node, "class", 0, VIR_XML_PROP_NONE, &def->usbClass) < 0) if (virXMLPropInt(node, "class", 0, VIR_XML_PROP_NONE, &def->usbClass) < 0)
goto error; return NULL;
if (def->usbClass != -1 && def->usbClass &~ 0xFF) { if (def->usbClass != -1 && def->usbClass &~ 0xFF) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Invalid USB Class code 0x%x"), def->usbClass); _("Invalid USB Class code 0x%x"), def->usbClass);
goto error; return NULL;
} }
def->vendor = -1; def->vendor = -1;
if (virXMLPropInt(node, "vendor", 0, VIR_XML_PROP_NONE, &def->vendor) < 0) if (virXMLPropInt(node, "vendor", 0, VIR_XML_PROP_NONE, &def->vendor) < 0)
goto error; return NULL;
def->product = -1; def->product = -1;
if (virXMLPropInt(node, "product", 0, VIR_XML_PROP_NONE, &def->product) < 0) if (virXMLPropInt(node, "product", 0, VIR_XML_PROP_NONE, &def->product) < 0)
goto error; return NULL;
version = virXMLPropString(node, "version"); version = virXMLPropString(node, "version");
if (version) { if (version) {
if (STREQ(version, "-1")) if (STREQ(version, "-1"))
def->version = -1; def->version = -1;
else if ((virDomainRedirFilterUSBVersionHelper(version, def)) < 0) else if ((virDomainRedirFilterUSBVersionHelper(version, def)) < 0)
goto error; return NULL;
} else { } else {
def->version = -1; def->version = -1;
} }
if (virXMLPropTristateBool(node, "allow", VIR_XML_PROP_REQUIRED, &allow) < 0) if (virXMLPropTristateBool(node, "allow", VIR_XML_PROP_REQUIRED, &allow) < 0)
goto error; return NULL;
def->allow = allow == VIR_TRISTATE_BOOL_YES; def->allow = allow == VIR_TRISTATE_BOOL_YES;
return def; return g_steal_pointer(&def);
error:
VIR_FREE(def);
return NULL;
} }
static virDomainRedirFilterDef * static virDomainRedirFilterDef *