From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8789 invoked by alias); 29 Jun 2017 23:30:55 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 8773 invoked by uid 89); 29 Jun 2017 23:30:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=cid, literally X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 29 Jun 2017 23:30:53 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 88B1FC0587D7; Thu, 29 Jun 2017 23:30:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 88B1FC0587D7 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=law@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 88B1FC0587D7 Received: from localhost.localdomain (ovpn-117-103.phx2.redhat.com [10.3.117.103]) by smtp.corp.redhat.com (Postfix) with ESMTP id 37020785EB; Thu, 29 Jun 2017 23:30:51 +0000 (UTC) Subject: Re: [PATCH] lto-wrapper.c (copy_file): Fix resource leaks To: Jakub Jelinek Cc: Sylvestre Ledru , gcc-patches@gcc.gnu.org References: <8ce6151e-5784-38d0-eabb-a2fc4ae1b4da@debian.org> <757053c3-b421-4c13-bc89-3dfda4618591@redhat.com> <20170626135809.GI2123@tucnak> <39205963-c810-9c2e-5830-f0ac08af9de1@redhat.com> <20170626152637.GJ2123@tucnak> From: Jeff Law Message-ID: <6d15d9e5-b35a-8a91-71b6-6b75c4441945@redhat.com> Date: Thu, 29 Jun 2017 23:30:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 In-Reply-To: <20170626152637.GJ2123@tucnak> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2017-06/txt/msg02346.txt.bz2 On 06/26/2017 09:26 AM, Jakub Jelinek wrote: > On Mon, Jun 26, 2017 at 09:22:31AM -0600, Jeff Law wrote: >>>>> From d255827a64012fb81937d6baa8534eabecf9b735 Mon Sep 17 00:00:00 2001 >>>>> From: Sylvestre Ledru >>>>> Date: Sun, 14 May 2017 11:37:37 +0200 >>>>> Subject: [PATCH 5/5] 2017-05-14 Sylvestre Ledru >>>>> >>>>> * lto-wrapper.c (copy_file): Fix resource leaks >>>>> CID 1407987, 1407986 >>>> Doesn't this still leak in the cases were we call fatal_error? >>> >>> fatal_error is a noreturn function, why should we bother to do any cleanups >>> after it? All that code is going to be optimized away anyway. >> But cleaning this kind of thing up does help static analyzers and such. >> ISTM that we'd need a compelling reason _not_ to accept this kind of patch. > > Are the static analyzers so dumb to report something like that? > > Unless we have a proof that they are, I think the original short patch is > the way to go, rather than the much more complicated later patch. The only thing that's complicated is how the formatting got mucked up in the patch :( It's literally just adding suitable fclose calls in the proper paths. I'm willing to go with the original in the hopes that it's enough to silence Coverity, but if Coverity still complains we should probably clean up the formatting and go with the latter patch. Sylvestre, please commit your original patch with this ChangeLog entry: * lto-wrapper.c (copy_file) Close both file descriptors before exiting normally. Jeff