From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28355 invoked by alias); 31 Jan 2013 20:29:58 -0000 Received: (qmail 28344 invoked by uid 22791); 31 Jan 2013 20:29:57 -0000 X-SWARE-Spam-Status: No, hits=-2.7 required=5.0 tests=AWL,BAYES_00,KHOP_SPAMHAUS_DROP,KHOP_THREADED,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from na3sys009aog114.obsmtp.com (HELO na3sys009aog114.obsmtp.com) (74.125.149.211) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 31 Jan 2013 20:29:52 +0000 Received: from mx20.qnx.com ([72.1.200.103]) (using TLSv1) by na3sys009aob114.postini.com ([74.125.148.12]) with SMTP ID DSNKUQrUP/Uh4NzPWbc6cc+42BOTFcgNkbYJ@postini.com; Thu, 31 Jan 2013 12:29:52 PST Received: by mx20.qnx.com (Postfix, from userid 500) id 4394420E1D; Thu, 31 Jan 2013 15:29:51 -0500 (EST) Received: from exhts.ott.qnx.com (exch2 [10.222.2.136]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mx20.qnx.com (Postfix) with ESMTPS id 04EA620A6E; Thu, 31 Jan 2013 15:29:51 -0500 (EST) Received: from [10.222.96.215] (10.222.2.5) by EXCH2.ott.qnx.com (10.222.2.136) with Microsoft SMTP Server (TLS) id 14.2.318.4; Thu, 31 Jan 2013 15:29:50 -0500 Message-ID: <510AD43E.3040405@qnx.com> Date: Thu, 31 Jan 2013 20:29:00 -0000 From: Aleksandar Ristovski User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 MIME-Version: 1.0 To: Tom Tromey CC: "gdb-patches@sourceware.org" Subject: Re: [patch] cleanup: Wunused corefile.c References: <510AC74E.1010709@qnx.com> <87vcad5cf1.fsf@fleche.redhat.com> In-Reply-To: <87vcad5cf1.fsf@fleche.redhat.com> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit 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 X-SW-Source: 2013-01/txt/msg00777.txt.bz2 On 13-01-31 03:24 PM, Tom Tromey wrote: >>>>>> "Aleksandar" == Aleksandar Ristovski writes: > > Aleksandar> In addition to already posted/committed Wunused I have a bunch of > Aleksandar> patches which work around unused vars by adding attribute unused. > > You should probably try a --enable-targets=all build if you want to > enable -Wunused in configure... > > Aleksandar> Rationale was: either it was unclear whether the assignment > Aleksandar> might have side-effects or there was something that should > Aleksandar> have been done (e.g. this case) with the variable. > > Aleksandar> Let me know if this is acceptable approach. > > It definitely isn't in this form, and perhaps not in other forms. > > First, in this case, the is just buggy. If stat fails, then st.st_mtime > isn't necessarily set, and so the subsequent test is reading garbage. > This is the sort of bug that -Wunused helps to diagnose -- so adding an > attribute to silence the error isn't what we should do. > > Second, using __attribute__ unconditionally isn't ok. We can use the > ATTRIBUTE_UNUSED macro; but I would imagine in most cases it would be > better to fix the problem in some other way. This is why I put a FIXME - intending to revisit and properly fix. But there are other cases where it is not about missing code, but e.g. conditional compilation. For example: Index: gdb/inflow.c =================================================================== RCS file: /cvs/src/src/gdb/inflow.c,v retrieving revision 1.69 diff -u -p -r1.69 inflow.c --- gdb/inflow.c 1 Jan 2013 06:32:45 -0000 1.69 +++ gdb/inflow.c 30 Jan 2013 22:25:15 -0000 @@ -397,7 +397,7 @@ terminal_ours_1 (int output_only) pgrp. */ void (*osigttou) () = NULL; #endif - int result; + int result __attribute__ ((unused)); #ifdef SIGTTOU if (job_control) However, I do not intend to push this very hard due to lack of time. I simply did a swipe over the code and made it compile with Wunused (without regressions) on x86_64-linux-gnu and wanted to contribute as much as I can without spending too much time on it. Thanks again, Aleksandar