From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22877 invoked by alias); 31 Jan 2013 20:24:40 -0000 Received: (qmail 22852 invoked by uid 22791); 31 Jan 2013 20:24:39 -0000 X-SWARE-Spam-Status: No, hits=-6.4 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,KHOP_SPAMHAUS_DROP,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 31 Jan 2013 20:24:06 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r0VKO3hC031965 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 31 Jan 2013 15:24:03 -0500 Received: from barimba (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r0VKO2qT018721 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Thu, 31 Jan 2013 15:24:02 -0500 From: Tom Tromey To: Aleksandar Ristovski Cc: "gdb-patches\@sourceware.org" Subject: Re: [patch] cleanup: Wunused corefile.c References: <510AC74E.1010709@qnx.com> Date: Thu, 31 Jan 2013 20:24:00 -0000 In-Reply-To: <510AC74E.1010709@qnx.com> (Aleksandar Ristovski's message of "Thu, 31 Jan 2013 14:34:38 -0500") Message-ID: <87vcad5cf1.fsf@fleche.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.92 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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/msg00776.txt.bz2 >>>>> "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. Tom