What we are using really is heap allocated structure rather than stack allocated. And for that it's better to use g_autoptr() + G_DEFINE_AUTOPTR_CLEANUP_FUNC() combo, as Glib documentation for g_auto() reads: This is meant to be used with stack-allocated structures and non-pointer types. For the (more commonly used) pointer version, see g_autoptr(). This will be even more visible, when virSysinfoDefPtr type is gone. Stay tuned. Fixes: cee3a900a0d6a8fc79554db22dc262632fe487a6 Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx> --- src/util/virsysinfo.c | 8 ++++---- src/util/virsysinfo.h | 2 +- tests/sysinfotest.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c index 0016028254..1c8193cc58 100644 --- a/src/util/virsysinfo.c +++ b/src/util/virsysinfo.c @@ -314,7 +314,7 @@ virSysinfoParsePPCProcessor(const char *base, virSysinfoDefPtr ret) virSysinfoDefPtr virSysinfoReadPPC(void) { - g_auto(virSysinfoDefPtr) ret = NULL; + g_autoptr(virSysinfoDef) ret = NULL; g_autofree char *outbuf = NULL; ret = g_new0(virSysinfoDef, 1); @@ -436,7 +436,7 @@ virSysinfoParseARMProcessor(const char *base, virSysinfoDefPtr ret) virSysinfoDefPtr virSysinfoReadARM(void) { - g_auto(virSysinfoDefPtr) ret = NULL; + g_autoptr(virSysinfoDef) ret = NULL; g_autofree char *outbuf = NULL; /* Some ARM systems have DMI tables available. */ @@ -602,7 +602,7 @@ virSysinfoParseS390Processor(const char *base, virSysinfoDefPtr ret) virSysinfoDefPtr virSysinfoReadS390(void) { - g_auto(virSysinfoDefPtr) ret = NULL; + g_autoptr(virSysinfoDef) ret = NULL; g_autofree char *outbuf = NULL; ret = g_new0(virSysinfoDef, 1); @@ -1212,7 +1212,7 @@ virSysinfoParseX86Memory(const char *base, virSysinfoDefPtr ret) virSysinfoDefPtr virSysinfoReadDMI(void) { - g_auto(virSysinfoDefPtr) ret = NULL; + g_autoptr(virSysinfoDef) ret = NULL; g_autofree char *outbuf = NULL; g_autoptr(virCommand) cmd = NULL; diff --git a/src/util/virsysinfo.h b/src/util/virsysinfo.h index 6b25969a4b..6ae4ba7bf3 100644 --- a/src/util/virsysinfo.h +++ b/src/util/virsysinfo.h @@ -157,7 +157,7 @@ void virSysinfoChassisDefFree(virSysinfoChassisDefPtr def); void virSysinfoOEMStringsDefFree(virSysinfoOEMStringsDefPtr def); void virSysinfoDefFree(virSysinfoDefPtr def); -G_DEFINE_AUTO_CLEANUP_FREE_FUNC(virSysinfoDefPtr, virSysinfoDefFree, NULL); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virSysinfoDef, virSysinfoDefFree); int virSysinfoFormat(virBufferPtr buf, virSysinfoDefPtr def) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); diff --git a/tests/sysinfotest.c b/tests/sysinfotest.c index 3b418955d0..e40a4564a7 100644 --- a/tests/sysinfotest.c +++ b/tests/sysinfotest.c @@ -91,7 +91,7 @@ testSysinfo(const void *data) { const struct testSysinfoData *testdata = data; const char *sysfsActualData; - g_auto(virSysinfoDefPtr) ret = NULL; + g_autoptr(virSysinfoDef) ret = NULL; g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; g_autofree char *sysinfo = NULL; g_autofree char *cpuinfo = NULL; -- 2.26.2