Re: let g_warn_if_fail replace g_assert



On Wed, 2007-10-17 at 09:44 -0700, Brian J. Tarricone wrote:
> Marco Barisione wrote:
> > Il giorno mer, 17/10/2007 alle 11.56 +0200, Tim Janik ha scritto:
> >> - add g_warn_if_fail (condition); which produces a critical
> >>    warning about failing assertions but contrary to g_assert
> >>    returns.
> > 
> > If it's called g_warn_if_fail() I would expect a g_warning() not a
> > g_critical().
> 
> Agreed -- and of course g_return_if_fail() does a g_warning(), so doing 
> a g_warning() on g_warn_if_fail() is kinda redundant.  How about 
> g_critical_if_fail()?
> 
> It's a shame tho that we can't encode the "it returns if it fails" 
> behavior in the name as well

I think the proposal is that g_warn_if_fail() shall return (in contrast
to g_assert(), which most of the time aborts the program), but it shall
not return from the function calling it. g_warn_if_fail() is supposed to
do exactly what its name implies: Just print a warning if a condition is
not met.

>  -- g_return_if_fail() is very clear what it 
> does (IMO, the fact that it also does a g_warning() is a 
> debugging-related bonus, not its primary purpose).  g_critical_if_fail() 
> sorta sounds like all it does is do a g_critical() if the condition 
> fails, and then continues on from that point.  I suppose 
> g_critical_return_if_fail() is a bit verbose (esp. when you consider 
> g_critical_return_val_if_fail() is even longer).  But I guess good API 
> docs will suffice ^_^.
> 

Armin



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