diff options
author | Alan Modra <amodra@gmail.com> | 2020-10-16 10:15:57 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2020-10-16 10:35:23 +1030 |
commit | e7f2f959e38e929ee04601abf97c4a637305771d (patch) | |
tree | 17325126904dab376d42c74a1317ef0e809847ff /bfd | |
parent | fd63a770b74293b20b150b83782f72d2f106f5c3 (diff) | |
download | gdb-e7f2f959e38e929ee04601abf97c4a637305771d.zip gdb-e7f2f959e38e929ee04601abf97c4a637305771d.tar.gz gdb-e7f2f959e38e929ee04601abf97c4a637305771d.tar.bz2 |
elf32-arc.c: Don't cast between function pointer and void pointer
Casts should be avoided if at all possible, and in particular the C
standard doesn't promise that function pointers can be cast to void*
or vice-versa. It is only mentioned under J.5 Common extensions,
saying "The following extensions are widely used in many systems, but
are not portable to all implementations."
* elf32-arc.c (replace_func): Correct return type.
(get_replace_function): Use a replace_func function pointer rather
than void*. Update associated ARC_RELOC_HOWTO define.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 6 | ||||
-rw-r--r-- | bfd/elf32-arc.c | 8 |
2 files changed, 10 insertions, 4 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 9595da0..a7e0cae 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,5 +1,11 @@ 2020-10-16 Alan Modra <amodra@gmail.com> + * elf32-arc.c (replace_func): Correct return type. + (get_replace_function): Use a replace_func function pointer rather + than void*. Update associated ARC_RELOC_HOWTO define. + +2020-10-16 Alan Modra <amodra@gmail.com> + * elf32-cr16.c: Formatting. (cr16_elf_final_link_relocate): Sign extend rather than clumsy "add or subtract" of offset value. Simplify range checks. Move diff --git a/bfd/elf32-arc.c b/bfd/elf32-arc.c index 7d282f3..a05f697 100644 --- a/bfd/elf32-arc.c +++ b/bfd/elf32-arc.c @@ -391,17 +391,17 @@ static const struct arc_reloc_map arc_reloc_map[] = #undef ARC_RELOC_HOWTO -typedef ATTRIBUTE_UNUSED bfd_vma (*replace_func) (unsigned, int ATTRIBUTE_UNUSED); +typedef ATTRIBUTE_UNUSED unsigned (*replace_func) (unsigned, int ATTRIBUTE_UNUSED); #define ARC_RELOC_HOWTO(TYPE, VALUE, SIZE, BITSIZE, RELOC_FUNCTION, OVERFLOW, FORMULA) \ case TYPE: \ - func = (void *) RELOC_FUNCTION; \ + func = RELOC_FUNCTION; \ break; static replace_func get_replace_function (bfd *abfd, unsigned int r_type) { - void *func = NULL; + replace_func func = NULL; switch (r_type) { @@ -411,7 +411,7 @@ get_replace_function (bfd *abfd, unsigned int r_type) if (func == replace_bits24 && bfd_big_endian (abfd)) func = replace_bits24_be; - return (replace_func) func; + return func; } #undef ARC_RELOC_HOWTO |