Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 19 Dec 2020 16:23:57 +0200
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Kevin Bowling <kevin.bowling@kev009.com>
Cc:        Ian Lepore <ian@freebsd.org>, Jessica Clarke <jrtc27@freebsd.org>, Mateusz Piotrowski <0mp@freebsd.org>, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r368714 - head/lib/libc/string
Message-ID:  <X94M/cQuHwf0R%2B2E@kib.kiev.ua>
In-Reply-To: <20201219135225.B6y3g%steffen@sdaoden.eu>
References:  <202012171241.0BHCfl1r008452@repo.freebsd.org> <X9tU0kTm9V6KoCRr@kib.kiev.ua> <686CF2E6-1D3C-4A83-A323-02CD9F536675@freebsd.org> <X9uFtba%2BjzVroNPV@kib.kiev.ua> <452cbb1060b7134315999c2323ed431714dc03fe.camel@freebsd.org> <CAK7dMtBP4L42-o01ohLoPdsRFV6yAiLjKREtDo_KL1ACWvA9qA@mail.gmail.com> <20201219135225.B6y3g%steffen@sdaoden.eu>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Dec 19, 2020 at 02:52:25PM +0100, Steffen Nurpmeso wrote:
> Kevin Bowling wrote in
>  <CAK7dMtBP4L42-o01ohLoPdsRFV6yAiLjKREtDo_KL1ACWvA9qA@mail.gmail.com>:
>  |On Thu, Dec 17, 2020 at 9:33 AM Ian Lepore <ian@freebsd.org> wrote:
>  |> On Thu, 2020-12-17 at 18:22 +0200, Konstantin Belousov wrote:
>  |>> On Thu, Dec 17, 2020 at 01:01:01PM +0000, Jessica Clarke wrote:
>  |>>> On 17 Dec 2020, at 12:53, Konstantin Belousov <kostikbel@gmail.com>
>  |>>> wrote:
>  |>>>> On Thu, Dec 17, 2020 at 12:41:47PM +0000, Mateusz Piotrowski
>  |>>>> wrote:
>  |>>>>> Author: 0mp (doc,ports committer)
>  |>>>>> Date: Thu Dec 17 12:41:47 2020
>  |>>>>> New Revision: 368714
>  |>>>>> URL: https://svnweb.freebsd.org/changeset/base/368714
>  ...
>  |>>>>> +       return (0);
>  |>>>>
>  |>>>> return (0) is redundand.
>  ...
>  |>> Why it is bad practice ?
>  |>>
>  |>> C is a small language, and while knowing some quirks (like this one)
>  |>> seems to be optional, others are not. And worse, that other quirks are
>  ...
>  |> How obscure is this quirk?  I've been writing C code since 1983,
>  |> including having released a freeware compiler (pre-gcc days) and
>  |> working on a commercial C compiler.  I used to moderate the c_language
>  |> conference on BIX (back when that was a thing).  I make my living
>  |> writing C and C++ code every day.  And yet, I had completely forgotten
>  |> about this quirk.
>  ...
>  |In Kib’s defense I think this is commonly mentioned in C99 books (at least
>  |that’s where I learned of it) so it depends on when and where someone
>  |learned.  There are merits approaches of being explicit or brief.  I have
> 
> Nicely said.  K&R C 2nd Ed. explicitly uses return(0) many times.

We are long after K&R in any of its form.

My point was that the example if of very low quality, and return (0); is
an indicator.  Perhaps even more interesting point to make is the mix of
return from main() and exit(3) use in same 4 lines.  Besides inconsistency,
exit(3) from main() should probably not used in examples or recommended
to novices at all.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?X94M/cQuHwf0R%2B2E>