From 065f7d5ba9999edd16332b381139dbca1ebae140 Mon Sep 17 00:00:00 2001 From: Laine Stump Date: Sat, 4 Jul 2020 18:09:21 -0400 Subject: [PATCH] remove redundant calls to virBufferFreeAndReset() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are several calls to virBufferFreeAndReset() when functions encounter an error, but the caller never uses the virBuffer once an error has been encountered (all callers detect error by looking at the function return value, not the contents of the virBuffer being operated on), and now that all virBuffers are auto-freed there is no reason for the lower level functions like these to spend time freeing a buffer that is guaranteed to be freed momentarily anyway. Signed-off-by: Laine Stump Reviewed-by: Ján Tomko --- src/conf/checkpoint_conf.c | 1 - src/conf/domain_conf.c | 1 - src/conf/snapshot_conf.c | 1 - src/libxl/xen_xl.c | 1 - src/util/virsysinfo.c | 1 - src/util/virxml.c | 1 - 6 files changed, 6 deletions(-) diff --git a/src/conf/checkpoint_conf.c b/src/conf/checkpoint_conf.c index 89d117043b..851c84f983 100644 --- a/src/conf/checkpoint_conf.c +++ b/src/conf/checkpoint_conf.c @@ -493,7 +493,6 @@ virDomainCheckpointDefFormatInternal(virBufferPtr buf, return 0; error: - virBufferFreeAndReset(buf); return -1; } diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3a110b330f..d33eb65f05 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -29970,7 +29970,6 @@ virDomainDefFormatInternalSetRootName(virDomainDefPtr def, return 0; error: - virBufferFreeAndReset(buf); return -1; } diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index 9767592bfc..b7ed3b42df 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -916,7 +916,6 @@ virDomainSnapshotDefFormatInternal(virBufferPtr buf, return 0; error: - virBufferFreeAndReset(buf); return -1; } diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index f4d6a631d1..a4b6bc3c9b 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -1432,7 +1432,6 @@ xenFormatXLVnode(virConfValuePtr list, ret = 0; cleanup: - virBufferFreeAndReset(buf); return ret; } diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c index dbca99c1ef..e69fc51a1e 100644 --- a/src/util/virsysinfo.c +++ b/src/util/virsysinfo.c @@ -1581,7 +1581,6 @@ virSysinfoFormat(virBufferPtr buf, virSysinfoDefPtr def) virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected sysinfo type model %d"), def->type); - virBufferFreeAndReset(buf); return -1; } diff --git a/src/util/virxml.c b/src/util/virxml.c index 1eaf390db2..78001363df 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -1284,7 +1284,6 @@ virXMLValidatorValidate(virXMLValidatorPtr validator, ret = 0; cleanup: - virBufferFreeAndReset(&validator->buf); return ret; }