Re: [libvirt] RFC: Use __attribute__ ((cleanup) in libvirt ?

2017-01-11 Thread Jim Fehlig
On 01/09/2017 09:58 AM, Daniel P. Berrange wrote: For those who don't already know, GCC and CLang both implement a C language extension that enables automatic free'ing of resources when variables go out of scope. This is done by annotating the variable with the "cleanup" attribute, pointing to a

Re: [libvirt] RFC: Use __attribute__ ((cleanup) in libvirt ?

2017-01-11 Thread Martin Kletzander
On Tue, Jan 10, 2017 at 11:54:19PM +, Richard W.M. Jones wrote: On Tue, Jan 10, 2017 at 10:00:31AM +, Daniel P. Berrange wrote: If we mandate use of gcc / clang, then we wouldn't need to hide it behind a macro - we'd be able to use it inline. That said, using a macro makes it smaller

Re: [libvirt] RFC: Use __attribute__ ((cleanup) in libvirt ?

2017-01-10 Thread Richard W.M. Jones
On Tue, Jan 10, 2017 at 10:00:31AM +, Daniel P. Berrange wrote: > If we mandate use of gcc / clang, then we wouldn't need to hide it > behind a macro - we'd be able to use it inline. That said, using a > macro makes it smaller and gives a bit of standardization. eg with > libguestfs style: >

Re: [libvirt] RFC: Use __attribute__ ((cleanup) in libvirt ?

2017-01-10 Thread Daniel P. Berrange
On Tue, Jan 10, 2017 at 05:05:21PM +0100, Michal Privoznik wrote: > On 01/09/2017 05:58 PM, Daniel P. Berrange wrote: > > > > I'm wondering what people think of making use of this in libvirt ? > > Apart from what have been said (I share the same concerns) I like the > idea. All the "limitations"

Re: [libvirt] RFC: Use __attribute__ ((cleanup) in libvirt ?

2017-01-10 Thread Michal Privoznik
On 01/09/2017 05:58 PM, Daniel P. Berrange wrote: > > I'm wondering what people think of making use of this in libvirt ? Apart from what have been said (I share the same concerns) I like the idea. All the "limitations" - we already have them. You have to initialize variables even when using

Re: [libvirt] RFC: Use __attribute__ ((cleanup) in libvirt ?

2017-01-10 Thread Martin Kletzander
On Tue, Jan 10, 2017 at 02:50:40PM +0100, Erik Skultety wrote: On Tue, Jan 10, 2017 at 02:17:00PM +0100, Martin Kletzander wrote: On Tue, Jan 10, 2017 at 10:00:31AM +, Daniel P. Berrange wrote: > On Tue, Jan 10, 2017 at 10:48:47AM +0100, Martin Kletzander wrote: > > On Tue, Jan 10, 2017 at

Re: [libvirt] RFC: Use __attribute__ ((cleanup) in libvirt ?

2017-01-10 Thread Erik Skultety
On Tue, Jan 10, 2017 at 01:55:02PM +, Daniel P. Berrange wrote: > On Tue, Jan 10, 2017 at 02:17:00PM +0100, Martin Kletzander wrote: > > On Tue, Jan 10, 2017 at 10:00:31AM +, Daniel P. Berrange wrote: > > > On Tue, Jan 10, 2017 at 10:48:47AM +0100, Martin Kletzander wrote: > > > > On Tue,

Re: [libvirt] RFC: Use __attribute__ ((cleanup) in libvirt ?

2017-01-10 Thread Daniel P. Berrange
On Tue, Jan 10, 2017 at 02:17:00PM +0100, Martin Kletzander wrote: > On Tue, Jan 10, 2017 at 10:00:31AM +, Daniel P. Berrange wrote: > > On Tue, Jan 10, 2017 at 10:48:47AM +0100, Martin Kletzander wrote: > > > On Tue, Jan 10, 2017 at 02:58:21AM -0500, Laine Stump wrote: > > > > On 01/09/2017

Re: [libvirt] RFC: Use __attribute__ ((cleanup) in libvirt ?

2017-01-10 Thread Erik Skultety
On Tue, Jan 10, 2017 at 02:17:00PM +0100, Martin Kletzander wrote: > On Tue, Jan 10, 2017 at 10:00:31AM +, Daniel P. Berrange wrote: > > On Tue, Jan 10, 2017 at 10:48:47AM +0100, Martin Kletzander wrote: > > > On Tue, Jan 10, 2017 at 02:58:21AM -0500, Laine Stump wrote: > > > > On 01/09/2017

Re: [libvirt] RFC: Use __attribute__ ((cleanup) in libvirt ?

2017-01-10 Thread Martin Kletzander
On Tue, Jan 10, 2017 at 10:00:31AM +, Daniel P. Berrange wrote: On Tue, Jan 10, 2017 at 10:48:47AM +0100, Martin Kletzander wrote: On Tue, Jan 10, 2017 at 02:58:21AM -0500, Laine Stump wrote: > On 01/09/2017 08:09 PM, Richard W.M. Jones wrote: > > On Mon, Jan 09, 2017 at 04:58:49PM +,

Re: [libvirt] RFC: Use __attribute__ ((cleanup) in libvirt ?

2017-01-10 Thread Daniel P. Berrange
On Tue, Jan 10, 2017 at 10:48:47AM +0100, Martin Kletzander wrote: > On Tue, Jan 10, 2017 at 02:58:21AM -0500, Laine Stump wrote: > > On 01/09/2017 08:09 PM, Richard W.M. Jones wrote: > > > On Mon, Jan 09, 2017 at 04:58:49PM +, Daniel P. Berrange wrote: > > > > For those who don't already

Re: [libvirt] RFC: Use __attribute__ ((cleanup) in libvirt ?

2017-01-10 Thread Martin Kletzander
On Tue, Jan 10, 2017 at 02:58:21AM -0500, Laine Stump wrote: On 01/09/2017 08:09 PM, Richard W.M. Jones wrote: On Mon, Jan 09, 2017 at 04:58:49PM +, Daniel P. Berrange wrote: For those who don't already know, GCC and CLang both implement a C language extension that enables automatic

Re: [libvirt] RFC: Use __attribute__ ((cleanup) in libvirt ?

2017-01-09 Thread Laine Stump
On 01/09/2017 08:09 PM, Richard W.M. Jones wrote: On Mon, Jan 09, 2017 at 04:58:49PM +, Daniel P. Berrange wrote: For those who don't already know, GCC and CLang both implement a C language extension that enables automatic free'ing of resources when variables go out of scope. This is done

Re: [libvirt] RFC: Use __attribute__ ((cleanup) in libvirt ?

2017-01-09 Thread Richard W.M. Jones
On Mon, Jan 09, 2017 at 04:58:49PM +, Daniel P. Berrange wrote: > For those who don't already know, GCC and CLang both implement a C language > extension that enables automatic free'ing of resources when variables go > out of scope. This is done by annotating the variable with the "cleanup" >

[libvirt] RFC: Use __attribute__ ((cleanup) in libvirt ?

2017-01-09 Thread Daniel P. Berrange
For those who don't already know, GCC and CLang both implement a C language extension that enables automatic free'ing of resources when variables go out of scope. This is done by annotating the variable with the "cleanup" attribute, pointing to a function the compiler will wire up a call to when