[libvirt PATCH] conf: use correct free function for virDomainVsockDef

Ján Tomko posted 1 patch 4 years, 2 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/0fa08b74c53a8c897dd7215a162359991dcdea3b.1580893549.git.jtomko@redhat.com
src/conf/domain_conf.c | 2 +-
src/conf/domain_conf.h | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
[libvirt PATCH] conf: use correct free function for virDomainVsockDef
Posted by Ján Tomko 4 years, 2 months ago
Technically, there is no memleak here, since the only
allocations are filled by virDomainDeviceInfoParseXML,
which cleans up after itself.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
---
 src/conf/domain_conf.c | 2 +-
 src/conf/domain_conf.h | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index c3214dc4f3..c7cc830c1d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -16458,7 +16458,7 @@ virDomainVsockDefParseXML(virDomainXMLOptionPtr xmlopt,
     xmlNodePtr cid;
     int val;
     g_autofree char *tmp = NULL;
-    g_autofree virDomainVsockDefPtr vsock = NULL;
+    g_autoptr(virDomainVsockDef) vsock = NULL;
 
     ctxt->node = node;
 
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index c3acb29e6f..2bd80c2fbf 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2891,6 +2891,7 @@ void virDomainFSDefFree(virDomainFSDefPtr def);
 void virDomainActualNetDefFree(virDomainActualNetDefPtr def);
 virDomainVsockDefPtr virDomainVsockDefNew(virDomainXMLOptionPtr xmlopt);
 void virDomainVsockDefFree(virDomainVsockDefPtr vsock);
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainVsockDef, virDomainVsockDefFree);
 void virDomainNetDefClear(virDomainNetDefPtr def);
 void virDomainNetDefFree(virDomainNetDefPtr def);
 void virDomainSmartcardDefFree(virDomainSmartcardDefPtr def);
-- 
2.21.0

Re: [libvirt PATCH] conf: use correct free function for virDomainVsockDef
Posted by Michal Privoznik 4 years, 2 months ago
On 2/5/20 10:06 AM, Ján Tomko wrote:
> Technically, there is no memleak here, since the only
> allocations are filled by virDomainDeviceInfoParseXML,
> which cleans up after itself.
> 
> Signed-off-by: Ján Tomko <jtomko@redhat.com>
> ---
>   src/conf/domain_conf.c | 2 +-
>   src/conf/domain_conf.h | 1 +
>   2 files changed, 2 insertions(+), 1 deletion(-)


Reviewed-by: Michal Privoznik <mprivozn@redhat.com>

Michal