There's this trend in libvirt of using enum types wherever possible. Now that I'm at virSecurityLabelDef let's rework @type item of the structure so we don't have to typecast it elsewhere. Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- src/conf/domain_conf.c | 6 ++++-- src/security/security_dac.c | 2 +- src/util/virseclabel.h | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index de60cd2..b3a0ec8 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4567,12 +4567,14 @@ virSecurityLabelDefParseXML(xmlXPathContextPtr ctxt, p = virXPathStringLimit("string(./@type)", VIR_SECURITY_LABEL_BUFLEN - 1, ctxt); if (p) { - seclabel->type = virDomainSeclabelTypeFromString(p); - if (seclabel->type <= 0) { + int type; /* virDomainSeclabelType */ + type = virDomainSeclabelTypeFromString(p); + if (type <= 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("invalid security type '%s'"), p); goto error; } + seclabel->type = type; } if (seclabel->type == VIR_DOMAIN_SECLABEL_STATIC || diff --git a/src/security/security_dac.c b/src/security/security_dac.c index 4d2a9d6..b4bfc57 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -1125,7 +1125,7 @@ virSecurityDACGenLabel(virSecurityManagerPtr mgr, return rc; } - switch ((virDomainSeclabelType) seclabel->type) { + switch (seclabel->type) { case VIR_DOMAIN_SECLABEL_STATIC: if (seclabel->label == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, diff --git a/src/util/virseclabel.h b/src/util/virseclabel.h index 94c4dfc..abf9510 100644 --- a/src/util/virseclabel.h +++ b/src/util/virseclabel.h @@ -39,7 +39,7 @@ struct _virSecurityLabelDef { char *label; /* security label string */ char *imagelabel; /* security image label string */ char *baselabel; /* base name of label string */ - int type; /* virDomainSeclabelType */ + virDomainSeclabelType type; /* seclabel @type */ bool relabel; /* true (default) for allowing relabels */ bool implicit; /* true if seclabel is auto-added */ }; -- 1.8.5.5 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list