[PATCH] Fixes for a small number of compiler warnings

H.J. Lu hjl.tools@gmail.com
Wed Apr 1 02:53:00 GMT 2015


On Tue, Mar 31, 2015 at 7:47 PM, Alan Modra <amodra@gmail.com> wrote:
> On Tue, Mar 31, 2015 at 09:25:41PM -0400, Hans-Peter Nilsson wrote:
>> On Wed, 1 Apr 2015, Alan Modra wrote:
>> > On Tue, Mar 31, 2015 at 04:47:10PM +0200, Ed Schouten wrote:
>> > > --- a/ld/emultempl/elf32.em
>> > > +++ b/ld/emultempl/elf32.em
>> > > @@ -1412,7 +1412,7 @@ gld${EMULATION_NAME}_before_allocation (void)
>> > >    asection *sinterp;
>> > >    bfd *abfd;
>> > >    struct elf_link_hash_entry *ehdr_start = NULL;
>> > > -  struct bfd_link_hash_entry ehdr_start_save = ehdr_start_save;
>> > > +  struct bfd_link_hash_entry ehdr_start_save = {};
>> > >
>> > >    if (is_elf_hash_table (link_info.hash))
>> > >      {
>> >
>> > Committed.
>>
>> earmelf.c: In function 'gldarmelf_before_allocation':
>> earmelf.c:1448:10: error: missing initializer
>> [-Werror=missing-field-initializers]earmelf.c:1448:10: error: (near initialization for 'ehdr_start_save.root') [-Werror=missing-field-initializers]
>> cc1: all warnings being treated as errors
>
> Let's just remove the init then.
>
> Older compilers that warn wrongly will just need -Wno-error.  No way
> am I going to init every single field, then have to edit this code
> whenever bfd_link_hash_entry changes.  Another option, making the
> struct static, isn't very nice since it means larger binaries and
> worse code.
>
>         * emultempl/elf32.em (gld${EMULATION_NAME}_before_allocation): Don't
>         init ehdr_start_save.
>
> diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
> index 2caddbe..ece2fb0 100644
> --- a/ld/emultempl/elf32.em
> +++ b/ld/emultempl/elf32.em
> @@ -1412,7 +1412,7 @@ gld${EMULATION_NAME}_before_allocation (void)
>    asection *sinterp;
>    bfd *abfd;
>    struct elf_link_hash_entry *ehdr_start = NULL;
> -  struct bfd_link_hash_entry ehdr_start_save = {};
> +  struct bfd_link_hash_entry ehdr_start_save;
>
>    if (is_elf_hash_table (link_info.hash))
>      {

This becomes a regression with the older GCC.  If we ask people to use
 -Wno-error, why single out older GCC like GCC 4.2?  We should either
do it automatically for all compilers or ask non-GCC users to add -Wno-error.

-- 
H.J.



More information about the Binutils mailing list