Keep with the recent effort of replacing as many explicit *Free
functions with their automatic equivalents.
Signed-off-by: Erik Skultety <eskultet@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
---
src/conf/domain_capabilities.h | 4 ++++
src/qemu/qemu_capabilities.c | 12 ++++--------
src/qemu/qemu_monitor_json.c | 11 ++++++-----
3 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h
index 755de1365f..45ebc436b9 100644
--- a/src/conf/domain_capabilities.h
+++ b/src/conf/domain_capabilities.h
@@ -25,6 +25,7 @@
# include "internal.h"
# include "domain_conf.h"
+# include "viralloc.h"
typedef const char * (*virDomainCapsValToStr)(int value);
@@ -215,4 +216,7 @@ char * virDomainCapsFormat(virDomainCapsPtr const caps);
void
virSEVCapabilitiesFree(virSEVCapability *capabilities);
+
+VIR_DEFINE_AUTOPTR_FUNC(virSEVCapability, virSEVCapabilitiesFree);
+
#endif /* __DOMAIN_CAPABILITIES_H__ */
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index e6e199b2c6..c17d26801e 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -5263,9 +5263,8 @@ static int
virQEMUCapsFillDomainFeatureSEVCaps(virQEMUCapsPtr qemuCaps,
virDomainCapsPtr domCaps)
{
- virSEVCapability *sev;
virSEVCapability *cap = qemuCaps->sevCapabilities;
- int ret = -1;
+ VIR_AUTOPTR(virSEVCapability) sev = NULL;
if (!cap)
return 0;
@@ -5274,19 +5273,16 @@ virQEMUCapsFillDomainFeatureSEVCaps(virQEMUCapsPtr qemuCaps,
return -1;
if (VIR_STRDUP(sev->pdh, cap->pdh) < 0)
- goto cleanup;
+ return -1;
if (VIR_STRDUP(sev->cert_chain, cap->cert_chain) < 0)
- goto cleanup;
+ return -1;
sev->cbitpos = cap->cbitpos;
sev->reduced_phys_bits = cap->reduced_phys_bits;
VIR_STEAL_PTR(domCaps->sev, sev);
- ret = 0;
- cleanup:
- virSEVCapabilitiesFree(sev);
- return ret;
+ return 0;
}
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 2921f110a9..3f99f39120 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -6443,9 +6443,11 @@ qemuMonitorJSONGetSEVCapabilities(qemuMonitorPtr mon,
virJSONValuePtr cmd;
virJSONValuePtr reply = NULL;
virJSONValuePtr caps;
- virSEVCapability *capability = NULL;
- const char *pdh = NULL, *cert_chain = NULL;
- unsigned int cbitpos, reduced_phys_bits;
+ const char *pdh = NULL;
+ const char *cert_chain = NULL;
+ unsigned int cbitpos;
+ unsigned int reduced_phys_bits;
+ VIR_AUTOPTR(virSEVCapability) capability = NULL;
*capabilities = NULL;
@@ -6476,7 +6478,7 @@ qemuMonitorJSONGetSEVCapabilities(qemuMonitorPtr mon,
}
if (virJSONValueObjectGetNumberUint(caps, "reduced-phys-bits",
- &reduced_phys_bits) < 0) {
+ &reduced_phys_bits) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("query-sev-capabilities reply was missing"
" 'reduced-phys-bits' field"));
@@ -6512,7 +6514,6 @@ qemuMonitorJSONGetSEVCapabilities(qemuMonitorPtr mon,
ret = 0;
cleanup:
- virSEVCapabilitiesFree(capability);
virJSONValueFree(cmd);
virJSONValueFree(reply);
--
2.14.4
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list