From owner-svn-src-all@FreeBSD.ORG Wed Jan 16 06:49:48 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id AD958E5A; Wed, 16 Jan 2013 06:49:48 +0000 (UTC) (envelope-from delphij@gmail.com) Received: from mail-qa0-f50.google.com (mail-qa0-f50.google.com [209.85.216.50]) by mx1.freebsd.org (Postfix) with ESMTP id 45A93D29; Wed, 16 Jan 2013 06:49:47 +0000 (UTC) Received: by mail-qa0-f50.google.com with SMTP id cr7so909067qab.9 for ; Tue, 15 Jan 2013 22:49:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=kzoNGIDzNKP0BE90ji8Hh9VwV+X0ymv2QSGqJI6WBUw=; b=pC4Ua6IlApoSQ7ShFUGpcFMzOpwp+eEz+8acYwMYvOR22Zt3X9xcuXsQfQ2hmFGQdS +0CwmZJMi2RE8tRcU/TpwSNM+SiSf27XuS09Rsv0E/KItHxVlSeNFcw71FJ00cyt44Vt stNeGl7Zy+iqxgNdO+aAZB8RGyZrlDwUNpethSCOXfvSPg0iUR9lG7eJaOQFBHyIQsTy 5t04kYXOCsg9rxQbUgFjM3Qtkd75FlDEik4qXgoR1uV4IhLlnsfxDoUeHbglTWr9A8Ak Zct33Czb9rEC+ShqauzWkLHruXCA5/CguVGITNSk1jbeHuR3dyYsvoEWUqwfSiVcIDG+ 6Tbg== MIME-Version: 1.0 X-Received: by 10.229.102.79 with SMTP id f15mr25719qco.1.1358318980980; Tue, 15 Jan 2013 22:49:40 -0800 (PST) Received: by 10.49.12.178 with HTTP; Tue, 15 Jan 2013 22:49:40 -0800 (PST) In-Reply-To: <201301160503.r0G53qie087155@svn.freebsd.org> References: <201301160503.r0G53qie087155@svn.freebsd.org> Date: Tue, 15 Jan 2013 22:49:40 -0800 Message-ID: Subject: Re: svn commit: r245494 - head/bin/pwait From: Xin LI To: Eitan Adler Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Cc: "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Jan 2013 06:49:48 -0000 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 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 https://www.delphij.net/ FreeBSD - The Power to Serve! Live free or die