From: Doug Evans <dje@google.com>
To: Sergio Durigan Junior <sergiodj@redhat.com>
Cc: binutils@sourceware.org, gdb-patches@sourceware.org,
Pedro Alves <palves@redhat.com>
Subject: Re: [RFC/PATCH] Fix `bfd_{get,set}_*' macros
Date: Thu, 03 May 2012 13:17:00 -0000 [thread overview]
Message-ID: <CADPb22RuF59twdBqbG3H=HG0JFg3aFtzeYh3tF7jimgWomEQuw@mail.gmail.com> (raw)
In-Reply-To: <m3mx5pyjzq.fsf@redhat.com>
On Wed, May 2, 2012 at 9:19 PM, Sergio Durigan Junior
<sergiodj@redhat.com> 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:
>
> bfd_get_section_name
> bfd_get_section_vma
> bfd_get_section_lma
> bfd_get_section_alignment
> bfd_section_name
> bfd_section_size
> bfd_get_section_flags
> bfd_get_section_userdata
>
> Those macros don't need the first argument (`bfd'), but they still
> require it. However, you can pass anything there and GCC won't complain
> about it, because the argument is unused after all. So, 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. GCC
> started to complain about it (unused argument). There were two paths
> that I could follow:
>
> 1) Delete the declaration of `bfd *', so this:
>
> bfd *abfd = objfile->abfd;
> bfd_get_section_name (abfd, sec);
>
> Would become:
>
> 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. I am labeling this patch as RFC because
> I'm not sure I fixed the code in the right way. It 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. Ok 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?
prev parent reply other threads:[~2012-05-03 13:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-03 4:19 Sergio Durigan Junior
2012-05-03 7:54 ` Alan Modra
2012-05-03 16:01 ` Pedro Alves
2012-05-03 16:22 ` Sergio Durigan Junior
2012-05-04 21:46 ` Sergio Durigan Junior
2012-05-10 1:54 ` Sergio Durigan Junior
2012-05-16 18:28 ` nick clifton
2012-05-16 19:48 ` Sergio Durigan Junior
2012-05-03 13:17 ` Doug Evans [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CADPb22RuF59twdBqbG3H=HG0JFg3aFtzeYh3tF7jimgWomEQuw@mail.gmail.com' \
--to=dje@google.com \
--cc=binutils@sourceware.org \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
--cc=sergiodj@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox