[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Always use SVN_ERR_ASSERT [was: svn commit: r1329234 - in /subversion/trunk: ./ subversion/libsvn_delta/compat.c]

From: Daniel Shahaf <danielsh_at_elego.de>
Date: Mon, 23 Apr 2012 19:29:44 +0300

Julian Foad wrote on Mon, Apr 23, 2012 at 17:18:22 +0100:
> I (Julian Foad) wrote:
>
> > There isn't currently an easy build switch (such as NDEBUG) to disable
> > SVN_ERR_ASSERT completely at compile time.  That's just a side issue.  If
> > you want such a switch, just ask; we can easily create one.  Or if you think we
> > need two levels of assertions -- one for quick tests and another for slow tests
> > -- and want to be able to compile-out the slow ones independently of the quick
> > ones, just ask.  But implying we should use 'assert' for slow tests and
> > 'SVN_ERR_ASSERT' for quick tests is the Wrong Way.
>
> We can also introduce run-time control of whether the conditions are evaluated: test a global 'assertions enabled?' variable or function before evaluating the condition.  For example:
>
> Index: subversion/include/svn_error.h
> ===================================================================
>  #define SVN_ERR_ASSERT(expr)                                            \
>    do {                                                                  \
> -    if (!(expr))                                                        \
> +    if (svn_error__assertions_enabled && !(expr))                       \
>        SVN_ERR(svn_error__malfunction(TRUE, __FILE__, __LINE__, #expr)); \
>    } while (0)
>  
> +/* ... */
> +extern svn_boolean_t svn_error__assertions_enabled;
>

That doesn't sound right. Surely we don't want to allow disabling _all_
uses of SVN_ERR_ASSERT() this way? (Remember that some of them
translate to segfaults (possibly corruptions?) if the condition doesn't
hold)

Perhaps we should have two flavours of the SVN_ERR_ASSERT() macros --
one unconditional and one only for developers.

Daniel

> - Julian
Received on 2012-04-23 18:30:30 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.