svn commit: r245494 - head/bin/pwait
Xin Li
delphij at delphij.net
Wed Jan 16 21:36:32 UTC 2013
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
On 01/16/13 08:11, John Baldwin wrote:
> On Wednesday, January 16, 2013 1:49:40 am Xin LI 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.
>>
>> Would you mind if I commit this changeset instead? I have the
>> return -> exit change in my queue long ago but only noticed it
>> today...
>
> I think the free shouldn't be there as well, but I think requiring
> an exit() instead of return to "fix" it is bogus as well. The
> static analyzer is just broken in this case. main() is special and
> returns from it should be treated like exit() and not cause false
> warnings about memory leaks.
Well, being a horrible idea itself to redefine main() to something
else and expect the module to do no harm to its caller, I think Eitan
still have a valid point that it could be a bad idea to ban this in
wholesale within compiler, as the C standard don't ban using return's
in main().
In style(9) the examples do use exit() for main() by the way.
Cheers,
- --
Xin LI <delphij at delphij.net> https://www.delphij.net/
FreeBSD - The Power to Serve! Live free or die
-----BEGIN PGP SIGNATURE-----
iQEcBAEBCgAGBQJQ9x1eAAoJEG80Jeu8UPuzIGsH/ia5cFVA2Uo6w1tEvbbAVMUi
+A580EYdQNdCFYVVGCIr6ZoCuZYsYqJdU0wT+xKjpE5qwaCfWVkESWbUGFVKUmFt
F1bFZfVu1TgntopYFj5goRyUVvsEutUgh/D8khZSKn9Mnu6ijbeq2CKJi0SyhySw
FcmGzp2YNk1B5BW8N8c4oRpLGvwtXPO4QBf5VAEoPU4ItY8bTukH2u09jOKaoh+7
J5eMU8KqWmxcuj6v5/8mb5iUN0oMprbdhVrpb0UpvIfM+TMQ3ISEbyJ5KeHW6dkV
5FLiu3arMe1p3k2yLrGYLB19lZfwtz3gM8QyorqAGK64uNY5oqwsA3UlIo01w48=
=V4kG
-----END PGP SIGNATURE-----
More information about the svn-src-head
mailing list