From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22103 invoked by alias); 27 Nov 2013 12:41:49 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 22088 invoked by uid 89); 27 Nov 2013 12:41:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.4 required=5.0 tests=AWL,BAYES_50,RDNS_NONE,URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: relay1.mentorg.com Received: from Unknown (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 27 Nov 2013 12:41:25 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1VleQX-0005Ag-R4 from Luis_Gustavo@mentor.com ; Wed, 27 Nov 2013 04:41:09 -0800 Received: from NA1-MAIL.mgc.mentorg.com ([147.34.98.181]) by svr-orw-fem-01.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Wed, 27 Nov 2013 04:41:09 -0800 Received: from [172.30.2.203] ([172.30.2.203]) by NA1-MAIL.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 27 Nov 2013 04:41:09 -0800 Message-ID: <5295E85A.1070109@codesourcery.com> Date: Wed, 27 Nov 2013 14:44:00 -0000 From: Luis Machado Reply-To: lgustavo@codesourcery.com User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: Doug Evans CC: "gdb-patches@sourceware.org" Subject: Re: [PATCH, testsuite] Prevent warnings due to dummy malloc calls. References: <5294F42D.6020007@codesourcery.com> <52951318.8010809@codesourcery.com> In-Reply-To: <52951318.8010809@codesourcery.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2013-11/txt/msg00841.txt.bz2 On 11/26/2013 07:31 PM, Luis Machado wrote: > On 11/26/2013 07:12 PM, Doug Evans wrote: >> On Tue, Nov 26, 2013 at 11:19 AM, Luis Machado >> wrote: >>> Hi, >>> >>> When running GDB's testsuite with libraries/compilers that are more >>> restrictive in terms of warnings, i've found that some tests were >>> failing >>> due to malloc being called but not having its return value assigned >>> to any >>> variables, leading to this warning: >>> >>> warning: ignoring return value of 'malloc', declared with attribute >>> warn_unused_result [-Wunused-result] >>> >>> The following patch adjusts those testcases to silence the warnings >>> by (1) >>> assigning malloc's return value and (2) freeing that pointer later on. >>> >>> In the case of gdb.base/randomize.c, we're missing a free call, which >>> leads >>> to an unused variable warning. >>> >>> Ok? >> >> Coping with these kinds of warnings is a really slippery slope, the >> testsuite is just not ready IMO. > > Agreed. I had the greatest idea of checking other warnings in the > testsuite... but i came back to my senses and dropped it for now. :-) > >> OTOH, I don't mind changes like this particular one. >> >> One nit: Please change all occurrences of this: >> >> + if (p != NULL) >> + free (p); >> >> to this >> >> + free (p); >> >> It's simpler and equally correct. > > Done! > >> >> The randomize.c case is a bit odd, printing p after it's freed. >> Maybe just add a comment explaining why things are the way they are? >> >> diff --git a/gdb/testsuite/gdb.base/randomize.c >> b/gdb/testsuite/gdb.base/randomize.c >> index 6a65663..127a4c7 100644 >> --- a/gdb/testsuite/gdb.base/randomize.c >> +++ b/gdb/testsuite/gdb.base/randomize.c >> @@ -24,5 +24,8 @@ int main() >> p = malloc (1); >> >> + if (p != NULL) >> + free (p); >> + >> return 0; /* print p */ >> } >> > > Yeah, this really needs a different change, as done in the attached patch. > > Thanks! > Luis I've checked this in now.