From: Peter Krempa Date: Mon, 24 Oct 2022 12:58:39 +0000 (+0200) Subject: virDomainTimerDef: Convert 'name' field to proper enum type X-Git-Tag: v8.10.0-rc1~229 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7fc2c872000eaf8b9906f3f0716f4baa38e6bcd2;p=thirdparty%2Flibvirt.git virDomainTimerDef: Convert 'name' field to proper enum type Adjust the type and the corresponding parser to use virXMLPropEnum. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7c718ce799..aa949766e1 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -10546,24 +10546,15 @@ virDomainTimerDefParseXML(xmlNodePtr node, VIR_XPATH_NODE_AUTORESTORE(ctxt) xmlNodePtr catchup; int ret; - g_autofree char *name = NULL; g_autofree char *tickpolicy = NULL; g_autofree char *track = NULL; g_autofree char *mode = NULL; ctxt->node = node; - name = virXMLPropString(node, "name"); - if (name == NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("missing timer name")); + if (virXMLPropEnum(node, "name", virDomainTimerNameTypeFromString, + VIR_XML_PROP_REQUIRED, &def->name) < 0) return NULL; - } - if ((def->name = virDomainTimerNameTypeFromString(name)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown timer name '%s'"), name); - return NULL; - } if (virXMLPropTristateBool(node, "present", VIR_XML_PROP_NONE, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index ba411bfa02..de6aefed2d 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2472,7 +2472,7 @@ struct _virDomainTimerCatchupDef { }; struct _virDomainTimerDef { - int name; + virDomainTimerNameType name; virTristateBool present; int tickpolicy; /* enum virDomainTimerTickpolicyType */