On Sat, Jul 21, 2018 at 05:36:57PM +0530, Sukrit Bhatnagar wrote: > By making use of GNU C's cleanup attribute handled by the > VIR_AUTOPTR macro for declaring aggregate pointer variables, > majority of the calls to *Free functions can be dropped, which > in turn leads to getting rid of most of our cleanup sections. > > Signed-off-by: Sukrit Bhatnagar <skrtbhtngr@xxxxxxxxx> > --- > src/util/virusb.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/src/util/virusb.c b/src/util/virusb.c > index c14683f..cfeac51 100644 > --- a/src/util/virusb.c > +++ b/src/util/virusb.c > @@ -508,8 +508,7 @@ void > virUSBDeviceListDel(virUSBDeviceListPtr list, > virUSBDevicePtr dev) > { > - virUSBDevicePtr ret = virUSBDeviceListSteal(list, dev); > - virUSBDeviceFree(ret); > + VIR_AUTOPTR(virUSBDevice) ret = virUSBDeviceListSteal(list, dev); > } > Technically, there's also a virUSBDevicePtr instance in virUSBDeviceSearch that could be converted to VIR_AUTOPTR, but virUSBDeviceListAdd would have to take a double pointer to @dev instead of a single pointer. A bit more background info - the current issue is that virUSBDeviceListAdd calls our VIR_APPEND_ELEMENT helper which does clear the original pointer which we could utilize here, but not while passing a single pointer. Not a deal breaker, though, it's just a nice to have, since you're already working in this area, because I don't suppose we'd make such a change any time soon after your assignment is over. (regardless) Reviewed-by: Erik Skultety <eskultet@xxxxxxxxxx> -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list