(In reply to comment #1)
> You should use g_clear_error() instead
I agree...
> I'm actually tempted to do a big s/g_error_free/g_clear_error/
... but I think this is going too far - it's often obvious that the error is both non-NULL and no longer used, for instance in this idiom for dealing with errors that there's no way to signal (yes that's a design flaw, but often one that we're stuck with medium-term):
(In reply to comment #1)
> You should use g_clear_error() instead
I agree...
> I'm actually tempted to do a big s/g_error_ free/g_ clear_error/
... but I think this is going too far - it's often obvious that the error is both non-NULL and no longer used, for instance in this idiom for dealing with errors that there's no way to signal (yes that's a design flaw, but often one that we're stuck with medium-term):
static void
foo (void)
{
GError *error = NULL;
if (do_a_thing (&error))
{
WARNING ("%s", error->message);
g_error_free (error);
}
}
or when interacting with dbus-glib:
static void on_dbus (DBusGMethodInv ocation *context)
do_something_
{
GError *error = NULL;
if (do_something (&error)) g_method_ return (context); g_method_ return_ error (context, error);
{
dbus_
}
else
{
dbus_
g_error_free (error);
}
}