Misuse of debugging functions
Brian J. Tarricone
bjt23 at cornell.edu
Thu Oct 7 22:51:55 CEST 2004
firstly, i agree that g_return_* and g_assert are for debugging. no
argument here.
philosophically, i'm against assert-type statements in anything but
applications, and then only if the error is unrecoverable (well, you can
assert to your heart's content, but releasing an app with asserts in it
where they aren't aborting on unrecoverable errors is just a bad practice
IMHO). an assert has _no_ place in a released library. an app should
never quit because a 3rd-party library decided it should.
as for the g_return_* functions, i tend to think that they should go at
the top of any and every function that takes pointers as parameters,
and that the function should return before attempting to access those
pointers if they aren't valid. the exception is in the case of functions
where it's valid to call them for NULL pointers, in which case the
function should know how to handle that case. sure, they're being used
for debugging in this case, but it makes it a hell of a lot easier to
track down a crash bug when you get a useful warning message that might
lead you to the cause. i guess the point here is that the messages are
harmless (if perhaps somewhat alarming) from the user's perspective.
gtk/glib uses this all over the place, and i think this is a Good
Thing[tm].
just my 2 cents, of course.
-brian
On 10/07/04 20:48, Benedikt Meurer wrote:
> I just had a discussion with Olivier on IRC about the usage of
> g_return_* and g_assert in Xfce apps. These functions are _debugging_
> functions, they aren't ment for regular programming. That says, a valid
> program would work even if these functions are stripped off. It seems
> that some parts of Xfce misuse these functions as a general replacement
> for normal checks. I'm aware that even some Gnome people do it this way,
> but it shouldn't be done this way. It'd be nice if we could pay a little
> more attention to this in the future.
>
> Benedikt
> _______________________________________________
> Xfce4-dev mailing list
> Xfce4-dev at xfce.org
> http://lunar-linux.org/mailman/listinfo/xfce4-dev
More information about the Xfce4-dev
mailing list