[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:13:32 +0300

Julian Foad wrote on Mon, Apr 23, 2012 at 17:01:33 +0100:
> Bert Huijben wrote:
>
> > you could just use
> > assert(svn_relpath_is_canonical(base_relpath)); for a debug only check. (or
> > SVN_ERR_ASSERT() if you also want to slow down release versions)
>
> The policy is: always use 'SVN_ERR_ASSERT' rather than 'assert' (in functions that return svn_error_t).
>
> Of course he doesn't "want to slow down" Subversion.
>
> The choice between 'assert' and 'SVN_ERR_ASSERT' should be based on whether we want an application program to be able to catch such a failure.  We long ago decided that the answer is YES we do want to write our library functions in such a way that an application can catch an assertion failure if its author chooses to do so.  SVN_ERR_ASSERT was introduces to fulfil that need.
>
> 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 we could do it on a case-by-case basis:

#ifndef NDEBUG
  SVN_ERR_ASSERT(system("exit $(find / | wc -l)") >= INT_MIN);
#endif
Received on 2012-04-23 18:14:13 CEST

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