Re: About gsettings aborting on unkown schemas



On Mon, May 30, 2011 at 8:17 PM, Morten Welinder <mortenw gnome org> wrote:
>> The core principle that allows most functions to "always succeed" is
>> that programming bugs are not "thrown," they just terminate the
>> program.
>
> Havoc, the data doesn't agree with that assertion.
> Let's look at numbers:
>
> glib, number of not-crashing on programmer errors:
> # find glib -type f -name '*.c' -print | xargs -n100 grep -E
> 'g_return_(val_)?if_fail' | wc -l
> 1509
>
> glib, number of crashing on programmer errors:
> # find glib '(' -type f -name '*.c' -print ')' -o '(' -type d -name
> tests -prune ')' | xargs -n100 grep -w -E 'g_assert|g_error' | wc -l
> 213
>
> gtk+, number of not-crashing on programmer errors:
> # find gtk '(' -type f -name '*.c' -print ')' -o '(' -type d -name
> tests -prune ')' | xargs -n100 grep -w -E 'g_return_(val_)?if_fail' |
> wc -l
> 5637
>
> gtk+, number of crashing on programmer errors:
> # find gtk '(' -type f -name '*.c' -print ')' -o '(' -type d -name
> tests -prune ')' | xargs -n100 grep -w -E 'g_assert|g_error' | wc -l
> 693
>
> So the overwhelming conclusion is that glib and gtk+ handle programmer
> errors by issuing a "critical" and returning. Not by crashing.
>
> It tips even more in that direction when you realize that a good
> fraction of the crashing calls do not actually catch (library user)
> programmer errors, but problems more in the memory-corruption
> department.
>
> We know that not having the schema around is not good.  Going postal
> and killing the program is not the solution.
>
> Doing a g_return_val_if_fail is fine here.  That will give the user a
> chance of saving his work.  This is in contrast to g_error which is a
> sure way of eating data.


This is getting very tiresome. Your statistics don't make any sense. A
programming error is a programming error, and the fact that we
indicate some of them with g_return_if_fail instead
of g_assert is a mere convention, not an invitation to handle them at runtime.

How about everybody who wants their programs to stumble along when
installed incorrectly just use g_settings_list_schemas() to determine
the presence of their schemas, instead of prolonging this discussion
even further ?

Thanks,

Matthias


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