[libvirt] [PATCH v3 2/4] qemu_process.c: use g_autoptr()

Jonathon Jongsma jjongsma at redhat.com
Thu Oct 17 20:12:24 UTC 2019


On Thu, 2019-10-17 at 17:08 -0300, Daniel Henrique Barboza wrote:
> 
> On 10/17/19 5:03 PM, Jonathon Jongsma wrote:
> > On Thu, 2019-10-17 at 09:46 -0300, Daniel Henrique Barboza wrote:
> > > Change all feasible pointers to use g_autoptr().
> > > 
> > > Signed-off-by: Daniel Henrique Barboza <danielhb413 at gmail.com>
> > > ---
> > >   src/qemu/qemu_process.c | 121 +++++++++++++------------------
> > > -------
> > > --
> > >   1 file changed, 40 insertions(+), 81 deletions(-)
> > > 
> > > diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
> > > index f747cdcc59..6ed69bef27 100644
> > > --- a/src/qemu/qemu_process.c
> > > +++ b/src/qemu/qemu_process.c
> > > @@ -108,7 +108,7 @@
> > > qemuProcessRemoveDomainStatus(virQEMUDriverPtr
> > > driver,
> > >       char ebuf[1024];
> > >       g_autofree char *file = NULL;
> > >       qemuDomainObjPrivatePtr priv = vm->privateData;
> > > -    virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
> > > +    g_autoptr(virQEMUDriverConfig) cfg =
> > > virQEMUDriverGetConfig(driver);
> > >       int ret = -1;
> > >   
> > >       if (virAsprintf(&file, "%s/%s.xml", cfg->stateDir, vm->def-
> > > > name) < 0)
> > > @@ -126,7 +126,6 @@
> > > qemuProcessRemoveDomainStatus(virQEMUDriverPtr
> > > driver,
> > >   
> > >       ret = 0;
> > >    cleanup:
> > > -    virObjectUnref(cfg);
> > 
> > It seems to me that if you're removing everything except the return
> > from the "cleanup"  label, there is no longer any use for the 'goto
> > cleanup' statement. You can replace it with a straight return.
> > There
> > are quite a few similar cases below.
> 
> This is being done in the next patch. This separation was given as a 
> feedback from the qemu_driver.c changes, where separating the
> 'cleanup'
> label removal from the auto* changes makes it easier to review.
> 

Yep, sorry. Please excuse the noise. I was apparently a little behind
on mailing list email and I both 1) replied to a slightly old version
of the patch series and 2) replied before reading the full patch
series. Carry on.

Jonathon




More information about the libvir-list mailing list