changes from v2:
- rebased with newer master (67e72053c1)
- added an extra patch to convert the existing VIR_AUTO* macros
to g_auto* ones, all at once, to avoid the case where a method
will have both VIR_AUTO* and g_auto* macros at the same time.
Note: the conversion in patch 10 wasn't 100% due to a handful of
methods that I was unable to use g_autoptr. Take for example
the method qemuDomainSaveInternal:
--
qemuDomainObjPrivatePtr priv = vm->privateData;
VIR_AUTOUNREF(virCapsPtr) caps = NULL;
virQEMUSaveDataPtr data = NULL;
VIR_AUTOUNREF(qemuDomainSaveCookiePtr) cookie = NULL;
--
Changing the 'cookie' variable to use g_autoptr() causes an error:
make[3]: Entering directory '/home/danielhb/kvm-project/libvirt/src'
CC qemu/libvirt_driver_qemu_impl_la-qemu_driver.lo
In file included from /usr/lib64/glib-2.0/include/glibconfig.h:9,
from /usr/include/glib-2.0/glib/gtypes.h:32,
from /usr/include/glib-2.0/glib/galloca.h:32,
from /usr/include/glib-2.0/glib.h:30,
from ./internal.h:31,
from qemu/qemu_agent.h:24,
from qemu/qemu_driver.c:40:
qemu/qemu_driver.c: In function 'qemuDomainSaveInternal':
qemu/qemu_driver.c:3282:15: error: unknown type name
'qemuDomainSaveCookie_autoptr'
3282 | g_autoptr(qemuDomainSaveCookie) cookie = NULL;
I tried doing it with the 'Ptr' in the name, same error:
CC qemu/libvirt_driver_qemu_impl_la-qemu_driver.lo
In file included from /usr/lib64/glib-2.0/include/glibconfig.h:9,
from /usr/include/glib-2.0/glib/gtypes.h:32,
from /usr/include/glib-2.0/glib/galloca.h:32,
from /usr/include/glib-2.0/glib.h:30,
from ./internal.h:31,
from qemu/qemu_agent.h:24,
from qemu/qemu_driver.c:40:
qemu/qemu_driver.c: In function 'qemuDomainSaveInternal':
qemu/qemu_driver.c:3282:15: error: unknown type name
'qemuDomainSaveCookiePtr_autoptr'
3282 | g_autoptr(qemuDomainSaveCookiePtr) cookie = NULL;
Similar situation happens with qemuDomainSaveImageStartVM and with
qemuSecurityInit methods. They are mentioned in the commit message
of patch 10 for reference. These methods are still using VIR_AUTO*
macros.
changes from v1:
- addressed review concerns made by Erik
- added more cleanups, as suggested by Erik
v2:
https://www.redhat.com/archives/libvir-list/2019-September/msg01452.html
v1:
https://www.redhat.com/archives/libvir-list/2019-September/msg00719.html
Daniel Henrique Barboza (10):
qemu_driver: use VIR_AUTOUNREF() with virQEMUDriverConfigPtr 1/3
qemu_driver: use VIR_AUTOUNREF() with virQEMUDriverConfigPtr 2/3
qemu_driver: use VIR_AUTOUNREF() with virQEMUDriverConfigPtr 3/3
qemu_driver: use VIR_AUTOUNREF() with virCapsPtr
qemu_driver: use VIR_AUTOUNREF() with more pointer types
qemu_driver: use VIR_AUTOFREE() with strings 1/3
qemu_driver: use VIR_AUTOFREE() with strings 2/3
qemu_driver: use VIR_AUTOFREE() with strings 3/3
qemu_driver: VIR_AUTOFREE on other scalar pointers
qemu_driver.c: use GLib macros
src/qemu/qemu_driver.c | 755 ++++++++++++++---------------------------
1 file changed, 259 insertions(+), 496 deletions(-)
--
2.21.0