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

Re: abort or verify?

From: Mark Benedetto King <mbk_at_lowlatency.com>
Date: 2004-11-10 16:58:29 CET

On Wed, Nov 10, 2004 at 03:29:59AM +0000, Julian Foad wrote:
> Julian Foad wrote:
> >In most of the places where we currently say:
> >
> > if (blah) abort();
> >
> >I feel we should be saying:
> >
> > assert(!blah);
>

I believe that we should always have code of the form:

    assert(!blah);
    if (blah)
      {
        /* do some reasonable thing */
      }

In some cases, that would manifest itself as:

    assert(x);
    if (!x)
      return svn_error_create(...);

In some cases, that would manifest itself as:

    assert(x);
    if (!x)
      abort();

Because the assertion generates such rich error messages,
it should be favored over abort(), but the abort() should
not be discarded when there is no reasonable way to proceed.

--ben

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Nov 10 16:48:02 2004

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.