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

Re: [libvirt] g_error considered harmful



On Tue, Jan 17, 2012 at 02:19:47PM +0100, Marc-André Lureau wrote:
> On Tue, Jan 17, 2012 at 2:05 PM, Christophe Fergeau <cfergeau redhat com> wrote:
> > And I forgot to mention that the only remaining use of g_error are in
> > gvir_init_object and gvir_init_config where it's probably acceptable to die
> > if things didn't work as expected.
> 
> Not really, it would be better to return an error.

Looking at what gtk+ does, it has gtk_init which is documented to abort,
and gtk_init_check which apps can use when they need this. g_type_init has
no _check alternative, but it does a few sanity checks at runtime using
g_assert.

I like the gtk+ approach of aborting in the function most commonly use as
it avoids tracking down bugs caused by the _init failing but not being
checked by the application developer. I think we should do the same and add
_check functions if/when needed (this is me being lazy)

Christophe

Attachment: pgpHmAeSIgNZg.pgp
Description: PGP signature


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