Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 22 Feb 2010 13:52:33 +0000 (UTC)
From:      "Bjoern A. Zeeb" <bz@FreeBSD.org>
To:        Robert Watson <rwatson@FreeBSD.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r204178 - head/games/fortune/fortune
Message-ID:  <20100222133112.D27327@maildrop.int.zabbadoz.net>
In-Reply-To: <alpine.BSF.2.00.1002221126240.80183@fledge.watson.org>
References:  <201002212103.o1LL3FGS037889@svn.freebsd.org> <alpine.BSF.2.00.1002221126240.80183@fledge.watson.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 22 Feb 2010, Robert Watson wrote:

Hi,

>
> On Sun, 21 Feb 2010, Ulrich Spoerlein wrote:
>
>>  Prefer exit(0) from main over return(0).
>>
>>  Although not explicitly mentioned in style(9), it allows for easier
>>  grepping of exit points. This reverts part of r203926.
>
> A few people (including me) have tripped up over exit handling and style in 
> the past.  It might be nice to formulate some specific sentences about 
> program exit paths, functions, and also return values, to put in the style 
> guide.
>
> For example, we have sysexits(3), but my understanding is we prefer not to 
> use it.  Likewise, we do like to use err()/warn() in preference to perror() 
> and exit(), etc.

I know better but still join this thread; the color shall be red
and light blue on white or a light blue on white depending on whether
you believe in the new or the old testament.

While the old testament seems to talk about exit() in 7.7 Error
Handling - Stderr and Exit but treated main() voidish apart from that
mostly, the new testament is a bit more precise in 7.6. with the same
name:

 	>>Withing main, return expr is equivalent to exit(expr). exit
 	has the advantage that it can be called from other functions,
 	and that calls to it can be found with a pattern-searching
 	program like those in Chapter 5.<<

It still seems to be quite common to use return rather than exit in
main(), and while style.9 may, in the future, possibly suggest that
exit() is the prefered token, we should not start changing all and
everything to exit() and still accept return() without major
bikesheds.

The thing I tripped over in the past were negative s,return,exit, (or
err(3)) values which are not really good(tm).


I agree with Robert that we should try to decide what, of all the
(unused or prefered by some people) possibilities we support, we
would prefer but may not forget portability.

/bz

-- 
Bjoern A. Zeeb         It will not break if you know what you are doing.
PS:    Whenever you commit to fortune, you will likely start a bikeshed.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100222133112.D27327>