Re: Reducing the weight of g_return_if_fail()



On Thu, 2004-09-09 at 20:33, Tim Janik wrote:
> On Thu, 9 Sep 2004, Owen Taylor wrote:
> 
> > On Tue, 2004-04-13 at 03:05, Tim Janik wrote:
> > > O
> > > > Which is a significant saving for such a tiny patch...
> > >
> > > looks good and makes sense to me. i'd just not call it
> > > g_return_failed_internal, that sounds as if a "return"
> > > failed. what's bad about "g_return_if_fail_internal" ?
> >
> > I want with g_return_if_fail_warning().
> 
> hm, looking at this again, i think putting "_return_" into
> a function name is not a good idea, it's ok for the macros
> though, since they actually do perform a "return" for you.
> so, better name it straight:

It's an internal helper function even if it's in the public ABI...
I'm not sure I want to spend a lot of time renaming it
one way or the other.

I think that g_assertion_failed() is wrong though, because the
function isn't suitable for use in g_assert() ... for g_assert(),
you most likely want the file/line information that was removed
in this patch.

The point being that 

 gtk_widget_show: assertion 'widget != NULL' failed 

is clear, adding gtkwidget.c:12345 adds nothing.

 next_link: assertion 'l->next != NULL' failed

is close to useless.

Regards,
					Owen

> +void g_assertion_failed      (const char *log_domain,
> +                              const char *pretty_function,
> +                              const char *expression);
> +
>  #define g_return_if_fail(expr)         G_STMT_START{                   \
>       if G_LIKELY(expr) { } else                                        \
>         {                                                               \
> -        g_log (G_LOG_DOMAIN,                                           \
> -               G_LOG_LEVEL_CRITICAL,                                   \
> -               "file %s: line %d (%s): assertion `%s' failed",         \
> -               __FILE__,                                               \
> -               __LINE__,                                               \
> -               __PRETTY_FUNCTION__,                                    \
> -               #expr);                                                 \
> +        g_assertion_failed       (G_LOG_DOMAIN,                        \
> +                                  __PRETTY_FUNCTION__,                 \
> +                                  #expr);                              \
>          return;                                                        \
>         };

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]