return_if_fail ideas for glib



I've run into this issue a lot. A parameter to a function is an enum.
There's a switch statement. The desired behavior of the default case of the
switch is a g_return_if_fail, but people use g_assert_not_reached because
there's there's no g_return_if_fail flavor that's right. I guess
g_return_if_fail (FALSE) could be used, but that seems kinda lame.

So should there be:

    g_return_if_reached
    g_return_val_if_reached

that work like g_return_if_fail?

Another idea is to have a g_message-like call that does a critical message,
for code that wants to do g_return_if_fail-link stuff in an if statement.

    g_critical_message

I can make the patch if people encourage me to do these. But I'll go back to
what I was doing and forget it if the maintainers aren't interested.

    -- Darin





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