From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5545 invoked by alias); 3 May 2012 13:17:48 -0000 Received: (qmail 5451 invoked by uid 22791); 3 May 2012 13:17:47 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=AWL,BAYES_00,BOTNET,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,KHOP_RCVD_TRUST,KHOP_THREADED,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,TW_BJ,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-vx0-f169.google.com (HELO mail-vx0-f169.google.com) (209.85.220.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 03 May 2012 13:17:30 +0000 Received: by vcbfy7 with SMTP id fy7so1574877vcb.0 for ; Thu, 03 May 2012 06:17:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding:x-system-of-record :x-gm-message-state; bh=3/JjkNRU+SYU2XHhCzLjgeTVxMTeErYGc8RFhgB/zJ4=; b=gHWp/998dt0DDOBrbFQ7vOcYN24qIGQUe40/+IF3tYI7q/5xICtFH+6YuTYLAneJfo P2wghagAMkrRUNOemDPjVvTVq7Hwrc1ZdELht08Ik7diWCGdiMrwJsQdBKiZFfZUrJz0 wg6MerHOEjE7MHi6JzefFMv+0P2u7qXBcdur07E9FHyIzTlA1WgfK1gYsMwHyRDnyzuv oZHgmtRCw33jjFFMc/VCeFulXIrx3NqZIWwCmAOHpxQRhl7UpmKWg9iqOEqPwAtPuobg vlMokTFvuUhH1YeeVLKLRRgm7EaM9rm4z1e5YPEtESx9xMxJqXsGHGgowR/Hf/ysGycs zg3g== Received: by 10.52.20.35 with SMTP id k3mr120714vde.44.1336051049103; Thu, 03 May 2012 06:17:29 -0700 (PDT) MIME-Version: 1.0 Received: by 10.52.20.35 with SMTP id k3mr120707vde.44.1336051049001; Thu, 03 May 2012 06:17:29 -0700 (PDT) Received: by 10.52.165.2 with HTTP; Thu, 3 May 2012 06:17:28 -0700 (PDT) In-Reply-To: References: Date: Thu, 03 May 2012 13:17:00 -0000 Message-ID: Subject: Re: [RFC/PATCH] Fix `bfd_{get,set}_*' macros From: Doug Evans To: Sergio Durigan Junior Cc: binutils@sourceware.org, gdb-patches@sourceware.org, Pedro Alves Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-System-Of-Record: true X-Gm-Message-State: ALoCoQlA+jhGuVKHk31Wku5G8NcGr4We2YpCC1npLpIN3gIJ8L6jJ+FypLBNrphSqaS7qI9J9H08xnv7LJqjR+CIF3+gVHB1nnsS6efRI1M2ytDms1b1Nxzfn7YIP1OS8lzU0Rk8Sjj0Kk21zUydjMMTxsN89IeGaA== X-IsSubscribed: yes 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: 2012-05/txt/msg00078.txt.bz2 On Wed, May 2, 2012 at 9:19 PM, Sergio Durigan Junior wrote: > Hi, > > As a part of an effort to enable `-Wunused-variable' on GDB build > system, I would like to propose this "fix" to the following macros > declared in bfd-in2.h: > > =A0bfd_get_section_name > =A0bfd_get_section_vma > =A0bfd_get_section_lma > =A0bfd_get_section_alignment > =A0bfd_section_name > =A0bfd_section_size > =A0bfd_get_section_flags > =A0bfd_get_section_userdata > > Those macros don't need the first argument (`bfd'), but they still > require it. =A0However, you can pass anything there and GCC won't complain > about it, because the argument is unused after all. =A0So, while fixing > GDB to support -Wunused-variable, I saw that there was a declaration of > a `bfd *', which is used as a first argument to those macros. =A0GCC > started to complain about it (unused argument). =A0There were two paths > that I could follow: > > 1) Delete the declaration of `bfd *', so this: > > =A0 bfd *abfd =3D objfile->abfd; > =A0 bfd_get_section_name (abfd, sec); > > Would become: > > =A0 bfd_get_section_name (objfile->abfd, sec); > > or > > 2) Fix the macros, so that they use the first argument in a safe way > like `(void) bfd', thus silencing GCC warnings. > > After having tried the first option, Pedro asked me to actually fix the > macros, so here is the patch to do this, along with small fixes through > the code in order to adapt it. =A0I am labeling this patch as RFC because > I'm not sure I fixed the code in the right way. =A0It wasn't clear to me > which `bfd' to use in each situation, so I used my best judgement (which > may not be good). > > As you will notice, I did not changed every bfd_*_section_* macro > because some of them are used as lvalue (left side of assignment). > > I regtested the patch on Fedora 16 x86_64 with GDB, without > regressions. =A0Ok to apply? I never liked these macros, it's like they had two "this" arguments. How much more work would it be to actually remove the bfd argument?