From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9018 invoked by alias); 16 Mar 2017 16:23:15 -0000 Mailing-List: contact newlib-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-owner@sourceware.org Received: (qmail 9002 invoked by uid 89); 16 Mar 2017 16:23:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy=markup, cid, H*i:sk:15a1051, H*f:sk:15a1051 X-HELO: a-painless.mh.aa.net.uk Received: from a-painless.mh.aa.net.uk (HELO a-painless.mh.aa.net.uk) (81.187.30.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 16 Mar 2017 16:23:13 +0000 Received: from 63.28.187.81.in-addr.arpa ([81.187.28.63] helo=home.pinkhut.co.uk) by a-painless.mh.aa.net.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1coYBE-0008AI-5G; Thu, 16 Mar 2017 16:23:12 +0000 Received: by home.pinkhut.co.uk (Postfix, from userid 1000) id 5F23260913D; Thu, 16 Mar 2017 16:22:58 +0000 (GMT) Date: Thu, 16 Mar 2017 16:23:00 -0000 From: Bob Dunlop To: Joel Sherrill Cc: newlib@sourceware.org Subject: Re: free() and implicit conversion to a function pointer (was: Use of initialized variable in strtod.c) Message-ID: <20170316162258.GA4797@xyzzy.org.uk> References: <20170316083958.GC16777@calimero.vinschen.de> <15a1051f-f3ae-5bd6-9b6c-4b284ed73704@oarcorp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <15a1051f-f3ae-5bd6-9b6c-4b284ed73704@oarcorp.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes X-SW-Source: 2017/txt/msg00189.txt.bz2 On Thu, Mar 16 at 10:04, Joel Sherrill wrote: > > On 3/16/2017 3:39 AM, Corinna Vinschen wrote: > > On Mar 15 18:48, Jeffrey Walton wrote: > >>> But this in __call_atexit.c is definitely correct. It is > >>> treating free() as a weak symbol and the only way to > >>> silence Coverity is to add an annotation. > >>> > >>> 136 /* Don't dynamically free the atexit array if free is not > >>> 137 available. */ > >>> > >>> CID 175323 (#1 of 1): Function address comparison (BAD_COMPARE) > >>> func_conv: This implicit conversion to a function pointer is suspicious: > >>> free. > >>> Did you intend to call free? > >>> 138 if (!free) > >>> 139 break; > >> > >> Well, I have not encountered that one (yet). Since Coverity is > >> complaining about an implicit conversion, maybe the following will > >> help to avoid the implicit part (and sidestep the finding): > >> > >> if (free != NULL) > >> break; > >> > >> Or perhaps: > >> > >> if ((void*)free != NULL) > >> break; > >> > >> If that works to clear the finding, then it is one of those items I > >> write-off as "working and playing well with the tools". > > > > Unfortunately you have to tell covreity that "free" is a var, not a function, > > but since that's not generally true... marking as false positive. > > > > Looks like the second option resolves the issue. No Coverity specific > markup at all. It seems better to be explicit since comparing a function > name to NULL directly is rather unusual. > > --joel Have you not just inverted the sense of the test as well. Shouldn't it be: if ((void*)free == NULL) break; -- Bob Dunlop