diff options
author | Alan Modra <amodra@gmail.com> | 2019-09-06 12:07:05 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2019-09-06 12:22:59 +0930 |
commit | b16c44debcf8a446e94e161e328169f5c8d5d811 (patch) | |
tree | f402c08e8f7fc00a404055e36c416580377f1b3a /bfd | |
parent | 6ade8373c9e689dece1057366b5adf9f8e86fa22 (diff) | |
download | gdb-b16c44debcf8a446e94e161e328169f5c8d5d811.zip gdb-b16c44debcf8a446e94e161e328169f5c8d5d811.tar.gz gdb-b16c44debcf8a446e94e161e328169f5c8d5d811.tar.bz2 |
bfd_get_filename
This macro says:
/* Cast from const char * to char * so that caller can assign to
a char * without a warning. */
I reckon that isn't such a good idea since it can result in char*
variables where const char* is appropriate. Not very many places
need the char* cast.
bfd/
* aout-target.h (object_p): Formatting.
* bfd-in.h (bfd_get_filename): Don't cast to char*.
* corefile.c (generic_core_file_matches_executable_p): Constify
variables and remove cast.
* bfd-in2.h: Regenerate.
binutils/
* nm.c (print_object_filename_bsd, print_object_filename_sysv),
(print_object_filename_posix, print_archive_filename_bsd),
(print_archive_filename_sysv, print_archive_filename_posix),
(print_archive_member_bsd, print_archive_member_sysv),
(print_archive_member_posix): Constify parameter.
(struct output_fns <print_object_filename, print_archive_filename>),
(<print_archive_member>): Likewise.
* objcopy.c (copy_archive): Add cast for make_tempdir.
ld/
* emultempl/elf32.em (gld${EMULATION_NAME}_search_needed): Constify
variable.
* emultempl/pe.em (gld_${EMULATION_NAME}_after_open): Likewise.
* emultempl/pep.em (gld_${EMULATION_NAME}_after_open): Likewise.
gdb/
* coffread.c (coff_symfile_read): Constify filename variable.
* dbxread.c (dbx_symfile_init, coffstab_build_psymtabs),
(elfstab_build_psymtabs, stabsect_build_psymtabs): Likewise.
* gdb_bfd.c (gdb_bfd_close_or_warn): Likewise.
* solib.c (reload_shared_libraries_1): Likewise.
* symfile.c (reread_symbols): Likewise.
* solib-aix.c (solib_aix_bfd_open): Add cast for xfree of filename.
* solib-darwin.c (darwin_bfd_open): Likewise.
* symfile-mem.c (symbol_file_add_from_memory): Likewise.
sim/cris/
* sim-if.c (sim_open): Constify filename variable.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 8 | ||||
-rw-r--r-- | bfd/aout-target.h | 2 | ||||
-rw-r--r-- | bfd/bfd-in.h | 4 | ||||
-rw-r--r-- | bfd/bfd-in2.h | 4 | ||||
-rw-r--r-- | bfd/corefile.c | 8 |
5 files changed, 15 insertions, 11 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 8ed849d..24f5e33 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,11 @@ +2019-09-06 Alan Modra <amodra@gmail.com> + + * aout-target.h (object_p): Formatting. + * bfd-in.h (bfd_get_filename): Don't cast to char*. + * corefile.c (generic_core_file_matches_executable_p): Constify + variables and remove cast. + * bfd-in2.h: Regenerate. + 2019-09-05 Alan Modra <amodra@gmail.com> * elf64-ppc.c (ppc64_elf_check_relocs): Interpret an addend in diff --git a/bfd/aout-target.h b/bfd/aout-target.h index 2f3d5ea..99a82bb 100644 --- a/bfd/aout-target.h +++ b/bfd/aout-target.h @@ -180,7 +180,7 @@ MY (object_p) (bfd *abfd) #ifndef S_IXUSR #define S_IXUSR 0100 /* Execute by owner. */ #endif - if (stat(abfd->filename, &buf) == 0 && (buf.st_mode & S_IXUSR)) + if (stat (abfd->filename, &buf) == 0 && (buf.st_mode & S_IXUSR)) abfd->flags |= EXEC_P; } #endif /* ENTRY_CAN_BE_ZERO */ diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h index a5e95d1..6544838 100644 --- a/bfd/bfd-in.h +++ b/bfd/bfd-in.h @@ -518,9 +518,7 @@ extern int bfd_stat (bfd *, struct stat *); #endif extern void _bfd_warn_deprecated (const char *, const char *, int, const char *); -/* Cast from const char * to char * so that caller can assign to - a char * without a warning. */ -#define bfd_get_filename(abfd) ((char *) (abfd)->filename) +#define bfd_get_filename(abfd) ((abfd)->filename) #define bfd_get_cacheable(abfd) ((abfd)->cacheable) #define bfd_get_format(abfd) ((abfd)->format) #define bfd_get_target(abfd) ((abfd)->xvec->name) diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 63b4792..7b1cfbc 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -525,9 +525,7 @@ extern int bfd_stat (bfd *, struct stat *); #endif extern void _bfd_warn_deprecated (const char *, const char *, int, const char *); -/* Cast from const char * to char * so that caller can assign to - a char * without a warning. */ -#define bfd_get_filename(abfd) ((char *) (abfd)->filename) +#define bfd_get_filename(abfd) ((abfd)->filename) #define bfd_get_cacheable(abfd) ((abfd)->cacheable) #define bfd_get_format(abfd) ((abfd)->format) #define bfd_get_target(abfd) ((abfd)->xvec->name) diff --git a/bfd/corefile.c b/bfd/corefile.c index aa43da5..b2b3d2e 100644 --- a/bfd/corefile.c +++ b/bfd/corefile.c @@ -157,9 +157,9 @@ DESCRIPTION bfd_boolean generic_core_file_matches_executable_p (bfd *core_bfd, bfd *exec_bfd) { - char *exec; - char *core; - char *last_slash; + const char *exec; + const char *core; + const char *last_slash; if (exec_bfd == NULL || core_bfd == NULL) return TRUE; @@ -169,7 +169,7 @@ generic_core_file_matches_executable_p (bfd *core_bfd, bfd *exec_bfd) non-const char *. In this case, the assignement does not lead to breaking the const, as we're only reading the string. */ - core = (char *) bfd_core_file_failing_command (core_bfd); + core = bfd_core_file_failing_command (core_bfd); if (core == NULL) return TRUE; |