svn commit: r245494 - head/bin/pwait

Xin LI delphij at gmail.com
Wed Jan 16 06:49:48 UTC 2013


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 at 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 at delphij.net> https://www.delphij.net/
FreeBSD - The Power to Serve! Live free or die


More information about the svn-src-head mailing list