invalid arguments to public API: g_assert, g_return_if_fail or continue with undefined behavior



I've noted significant inconsistencies wrt the handling of invalid
arguments to functions. While GTK+ seems to take care of notifying the
API client about failures by having various g_return_if_fail statements
in front of virtually every public API, the EvolutionDataServer
according to Sven Herzberg has asserts in the very beginning of many
public API codeblocks. GnomeVFS instead often seems to not check for
this at all, resulting in NULL strcmps etc.. Just check out
gnome-vfs-mime-handlers.c and you get the gist.

I'd really like to have a GNOME-wide policy for dealing with public API
and invalid arguments. If we feel like the traditional C route is good,
we can remove all of these codeblocks for the sake of performance. I
think some of the asserts/return_if_fail statements were left out for
exactly that reason. I suppose this has a measurable performance impact
for little helpers that are often called.

On the other hand, programmers using our API will probably kill us if we
remove them. So maybe we've got to make a decision whether we should
enforce the usage of g_assert or g_return_if_fail.

-- 
Christian Neumair <chris gnome-de org>

Attachment: signature.asc
Description: This is a digitally signed message part



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