This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PATCH: Avoid warning from -Wjump-misses-init
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Ian Lance Taylor <iant at google dot com>
- Cc: binutils at sources dot redhat dot com
- Date: Sun, 21 Jun 2009 12:11:25 -0700
- Subject: Re: PATCH: Avoid warning from -Wjump-misses-init
- References: <20090620131455.GA22320@lucon.org> <m3eitei47b.fsf@google.com>
On Sat, Jun 20, 2009 at 9:46 PM, Ian Lance Taylor<iant@google.com> wrote:
> "H.J. Lu" <hongjiu.lu@intel.com> writes:
>
>> Index: bfd/elflink.c
>> ===================================================================
>> --- bfd/elflink.c ? ? (revision 6199)
>> +++ bfd/elflink.c ? ? (working copy)
>> @@ -3549,7 +3549,11 @@ elf_link_add_object_symbols (bfd *abfd,
>> ? ? ? ? unsigned long shlink;
>>
>> ? ? ? ? if (!bfd_malloc_and_get_section (abfd, s, &dynbuf))
>> - ? ? ? ? goto error_free_dyn;
>> + ? ? ? ? {
>> +error_free_dyn:
>> + ? ? ? ? ? free (dynbuf);
>> + ? ? ? ? ? goto error_return;
>> + ? ? ? ? }
>>
>> ? ? ? ? elfsec = _bfd_elf_section_from_bfd_section (abfd, s);
>> ? ? ? ? if (elfsec == SHN_BAD)
>> @@ -3633,11 +3637,7 @@ elf_link_add_object_symbols (bfd *abfd,
>> ? ? ? ? ? ? ? ? amt = strlen (fnm) + 1;
>> ? ? ? ? ? ? ? ? anm = bfd_alloc (abfd, amt);
>> ? ? ? ? ? ? ? ? if (anm == NULL)
>> - ? ? ? ? ? ? ? ? {
>> - ? ? ? ? ? ? ? ? error_free_dyn:
>> - ? ? ? ? ? ? ? ? ? free (dynbuf);
>> - ? ? ? ? ? ? ? ? ? goto error_return;
>> - ? ? ? ? ? ? ? ? }
>> + ? ? ? ? ? ? ? ? goto error_free_dyn;
>
>
> This doesn't seem to me to be a good fix. ?This code is ugly. ?If you're
> going to touch it, clean it up. ?error_free_dyn should be at the end of
> the function, like all the other error labels.
>
dybuf is a local variable in that block. It is allocated and freed
within that block. My fix is the minimal one.
--
H.J.