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

Re: svn commit: r1222522 - /subversion/branches/1.7.x/STATUS

From: Stefan Küng <tortoisesvn_at_gmail.com>
Date: Sat, 24 Dec 2011 17:24:51 +0100

On 24.12.2011 17:01, Branko Čibej wrote:
> On 24.12.2011 16:57, Stefan Küng wrote:
>> an assert implies that you _know_ something is wrong and you could
>> back out without taking the process down with you
>
> No. That is inappropriate usage of assertions. Assert means that if the
> condition is not met, you cannot continue. One should not use assertions
> for, e.g., validation of public API parameters.

So, in case of e.g. a corrupted working copy which has paths messed up
(and you know that the paths are messed up), then you would agree that
returning an error like "paths not correct, wc might be corrupted" and
let the application continue would be better than just aborting the
process? Yes?

Then why are there multiple statements like this in the svn code:
   SVN_ERR_ASSERT_NO_RETURN(svn_dirent_is_absolute(local_abspath));
(example from libsvn_wc\util.c, line 197).

A simple SVN_ERR_ASSERT() would be much better, but no, the whole
process is not allowed to proceed (notice the _NO_RETURN) and must be
aborted.

That's just one example of many, many more. A simple search for
SVN_ERR_ASSERT_NO_RETURN will give you an idea. I only found about two
which I would consider real _NO_RETURN situations. All others are
completely recoverable.

I have no problems with asserts, or even the _NO_RETURN asserts if they
are used right. _NO_RETURN must not be used where the situation is
recoverable.

Stefan

-- 
        ___
   oo  // \\      "De Chelonian Mobile"
  (_,\/ \_/ \     TortoiseSVN
    \ \_/_\_/>    The coolest Interface to (Sub)Version Control
    /_/   \_\     http://tortoisesvn.net
Received on 2011-12-24 17:25:34 CET

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.