Re: [PATCH 06/15] virbitmaptest: Use g_auto(free) for cleanup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Oct 02, 2020 at 10:50:55 +0200, Ján Tomko wrote:
> On a Friday in 2020, Peter Krempa wrote:
> > Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
> > ---
> > tests/virbitmaptest.c | 73 ++++++++++++++-----------------------------
> > 1 file changed, 24 insertions(+), 49 deletions(-)
> > 
> > diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c
> > index 1578cd0612..bfca208a7f 100644
> > --- a/tests/virbitmaptest.c
> > +++ b/tests/virbitmaptest.c
> > @@ -185,7 +181,7 @@ test4(const void *data G_GNUC_UNUSED)
> >         1, 5, 11, 13, 19, 21, 23, 24, 26, 27,
> >         28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39
> >     };
> > -    virBitmapPtr bitmap = NULL;
> > +    g_autoptr(virBitmap) bitmap = NULL;
> 
> Here, bitmap is also freed in the middle of the function
> (it seems these are three independent tests squashed into one function)

What's worse, test4 actually doesn't report any errors if any of the
cases would fail. You'd have to use a debugger to figure out what's
wrong.

Note that all of the cases you mention below actually clear the pointer
when the contents are freed, so this patch is still correctly handling
the memory.

Should I post another version where I add separate variables for any
reuse?




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux