Re: [PATCH v1 04/32] util: macaddr: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC

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

 



On Fri, Aug 03, 2018 at 09:34:51AM +0200, Erik Skultety wrote:
> On Fri, Aug 03, 2018 at 09:30:22AM +0200, Erik Skultety wrote:
> > On Sat, Jul 28, 2018 at 11:31:19PM +0530, Sukrit Bhatnagar wrote:
> > > Using the new VIR_DEFINE_AUTOPTR_FUNC macro defined in
> > > src/util/viralloc.h, define a new wrapper around an existing
> > > cleanup function which will be called when a variable declared
> > > with VIR_AUTOPTR macro goes out of scope. Also, drop the redundant
> > > viralloc.h include, since that has moved from the source module into
> > > the header.
> > >
> > > When a variable of type virMacAddrPtr is declared using VIR_AUTOPTR,
> > > the function virMacAddrFree will be run automatically on it when it
> > > goes out of scope.
> > >
> > > Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@xxxxxxxxx>
> > > ---
> > >  src/util/virmacaddr.c | 6 ++++++
> > >  src/util/virmacaddr.h | 4 ++++
> > >  2 files changed, 10 insertions(+)
> > >
> > > diff --git a/src/util/virmacaddr.c b/src/util/virmacaddr.c
> > > index 7afe032..e739775 100644
> > > --- a/src/util/virmacaddr.c
> > > +++ b/src/util/virmacaddr.c
> > > @@ -252,3 +252,9 @@ virMacAddrIsBroadcastRaw(const unsigned char s[VIR_MAC_BUFLEN])
> > >  {
> > >      return memcmp(virMacAddrBroadcastAddrRaw, s, sizeof(*s)) == 0;
> > >  }
> > > +
> > > +void
> > > +virMacAddrFree(virMacAddrPtr addr)
> > > +{
> > > +    VIR_FREE(addr);
> > > +}
> >
> > I understand the reason behind this change, however, I don't feel like this
> > will bring any benefits only because we said that VIR_AUTOFREE should be used
> > with scalar types only, I'd prefer simply using VIR_AUTOFREE here, CC'ng Pavel
> > to share his opinion.

Sigh, I just realized we already have virPCIDeviceAddressFree which does the
very same thing (possibly more of those) which I missed during the review
of the previous batches. Oh well, we might have to go with this in the end in
order not to cause more confusion.

Erik

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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