Date: Tue, 15 Jan 2013 22:49:40 -0800 From: Xin LI <delphij@gmail.com> To: Eitan Adler <eadler@freebsd.org> Cc: "svn-src-head@freebsd.org" <svn-src-head@freebsd.org>, "svn-src-all@freebsd.org" <svn-src-all@freebsd.org>, "src-committers@freebsd.org" <src-committers@freebsd.org> Subject: Re: svn commit: r245494 - head/bin/pwait Message-ID: <CAGMYy3smQv4-3oxZBFC1EkJQr%2B=3n08z=tBr_Lt58zxfTcYB6Q@mail.gmail.com> In-Reply-To: <201301160503.r0G53qie087155@svn.freebsd.org> References: <201301160503.r0G53qie087155@svn.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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... Index: pwait.c =================================================================== --- pwait.c (revision 245497) +++ pwait.c (working copy) @@ -141,6 +141,5 @@ main(int argc, char *argv[]) nleft -= n; } - free(e); - return 0; + exit(EX_OK); } Cheers, On Tue, Jan 15, 2013 at 9:03 PM, Eitan Adler <eadler@freebsd.org> wrote: > Author: eadler > Date: Wed Jan 16 05:03:52 2013 > New Revision: 245494 > URL: http://svnweb.freebsd.org/changeset/base/245494 > > Log: > Free memory before exiting in order to silence a warning from the clang > static analyzer > > Approved by: cperciva > MFC after: 3 days > > Modified: > head/bin/pwait/pwait.c > > Modified: head/bin/pwait/pwait.c > > ============================================================================== > --- head/bin/pwait/pwait.c Wed Jan 16 05:03:49 2013 (r245493) > +++ head/bin/pwait/pwait.c Wed Jan 16 05:03:52 2013 (r245494) > @@ -141,5 +141,6 @@ main(int argc, char *argv[]) > nleft -= n; > } > > + free(e); > return 0; > } > -- Xin LI <delphij@delphij.net> https://www.delphij.net/ FreeBSD - The Power to Serve! Live free or die
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAGMYy3smQv4-3oxZBFC1EkJQr%2B=3n08z=tBr_Lt58zxfTcYB6Q>