<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <font size="+1">I just realized by reading a patch from Jano that
      VIR_AUTOFREE<br>
      is simply an alias for g_autofree. This means that it is not worth<br>
      to add more VIR_AUTOFREE() macros, and that it is ok to mix<br>
      g_autofree with other VIR_ macros such as VIR_AUTOUNREF(). Jano is<br>
      also removing VIR_AUTOFREE() from the code in his series, which<br>
      will make this whole series obsolete.<br>
      <br>
      I'll re-send this series to not add more VIR_AUTOFREE() in any<br>
      step of the way.<br>
      <br>
      <br>
      DHB<br>
      <br>
    </font><br>
    <div class="moz-cite-prefix">On 10/15/19 5:08 PM, Daniel Henrique
      Barboza wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:20191015200852.15778-1-danielhb413@gmail.com">
      <pre class="moz-quote-pre" wrap="">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: <a class="moz-txt-link-freetext" href="https://www.redhat.com/archives/libvir-list/2019-September/msg01452.html">https://www.redhat.com/archives/libvir-list/2019-September/msg01452.html</a>
v1: <a class="moz-txt-link-freetext" href="https://www.redhat.com/archives/libvir-list/2019-September/msg00719.html">https://www.redhat.com/archives/libvir-list/2019-September/msg00719.html</a>

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(-)

</pre>
    </blockquote>
    <br>
  </body>
</html>