Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 Jan 2013 10:17:20 -0800
From:      Garrett Cooper <yanegomi@gmail.com>
To:        "d@delphij.net" <d@delphij.net>
Cc:        "svn-src-head@freebsd.org" <svn-src-head@freebsd.org>, Xin LI <delphij@gmail.com>, "svn-src-all@freebsd.org" <svn-src-all@freebsd.org>, "src-committers@freebsd.org" <src-committers@freebsd.org>, Eitan Adler <eadler@freebsd.org>
Subject:   Re: svn commit: r245494 - head/bin/pwait
Message-ID:  <0928E58E-F510-47CD-957F-8C321B1210CC@gmail.com>
In-Reply-To: <50F6ED68.50602@delphij.net>
References:  <201301160503.r0G53qie087155@svn.freebsd.org> <CAGMYy3smQv4-3oxZBFC1EkJQr%2B=3n08z=tBr_Lt58zxfTcYB6Q@mail.gmail.com> <CAF6rxgmthYBdGeZkRaDHL0bDYCHb_pKPQiGKaWmU2id0Cd_A5g@mail.gmail.com> <50F6ED68.50602@delphij.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Jan 16, 2013, at 10:11 AM, Xin Li <delphij@delphij.net> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA512
>=20
> On 01/16/13 09:47, Eitan Adler wrote:
>> On 16 January 2013 01:49, Xin LI <delphij@gmail.com> wrote:
>>> This doesn't seem right -- you should never release memory before
>>> exit, especially for memory allocated in main(), unless this
>>> "main" is intended for different purpose like a monolithic shell
>>> that wants to avoid exec(). Note that pwait(1) have multiple exit
>>> points I don't think it's practical.
>>=20
>> ...
>>=20
>> There have been multiple conversations about this: on hackers, on
>> the commit lists, and on the clang analyzer lists.
>>=20
>> I don't care much how the final code looks: with either free or
>> return but please make sure that scan-build finds no warnings.
>=20
> Yes I did.  Using exit(3) tells clang that this is the final exit and
> thus eliminates the warning.
>=20
> It sounds like a bug (or arguably a feature) that clang does not
> recognize return in main()s...

    I would consider it a bug, but it's better to use exit(3) anyhow as it p=
revents bugs from occurring in other OSes (like windows when you use atexit a=
nd posix-compliant signal handlers).
Thanks,
-Garrett=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?0928E58E-F510-47CD-957F-8C321B1210CC>