rel/rela patch for get_dynamic_reloc_section_name
H.J. Lu
hjl.tools@gmail.com
Tue Feb 22 15:35:00 GMT 2011
On Tue, Feb 22, 2011 at 7:31 AM, Nick Clifton <nickc@redhat.com> wrote:
> Hi Bernd,
>
> + name = bfd_alloc (abfd, (is_rela ? 6 : 5) + strlen (old_name));
> + if (is_rela)
> + strcpy (name, ".rela");
> + else
> + strcpy (name, ".rel");
> + strcat (name, old_name);
>
> I dislike seeing magic constants like "6" and "5" in the code above. How
> about rewriting this as:
>
> const char * prefix = is_rela ? ".rela" : ".rel";
> name = bfd_alloc (abfd, strlen (prefix) + strlen (old_name) + 1);
> sprintf (name, "%s%s", prefix, old_name);
>
Why not just use (is_rela ? sizeof (.rela) -1: sizeof (.rel) - 1)
--
H.J.
More information about the Binutils
mailing list