From f995bbe8e62fdb5607acb1ee127240cfe50d2b8f Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Wed, 5 Apr 2017 19:21:33 +0100 Subject: -Wwrite-strings: Constify struct disassemble_info's disassembler_options field The memory disassemble_info::disassembler_options points to is always owned by the client. I.e., that field is an non-owning, observing pointer. Thus const makes sense. Are the include/ and opcodes/ bits OK? Tested on x86_64 Fedora 23, built with --enable-targets=all. include/ChangeLog: 2017-04-05 Pedro Alves * dis-asm.h (disassemble_info) : Now a "const char *". (next_disassembler_option): Constify. opcodes/ChangeLog: 2017-04-05 Pedro Alves * arc-dis.c (parse_option, parse_disassembler_options): Constify. * arm-dis.c (parse_arm_disassembler_options): Constify. * ppc-dis.c (powerpc_init_dialect): Constify local. * vax-dis.c (parse_disassembler_options): Constify. gdb/ChangeLog: 2017-04-05 Pedro Alves * arm-tdep.c (show_disassembly_style_sfunc): Constify local. * disasm.c (set_disassembler_options): Constify local. * i386-tdep.c (i386_print_insn): Remove cast and FIXME comment. --- include/ChangeLog | 6 ++++++ include/dis-asm.h | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/ChangeLog b/include/ChangeLog index fa0f3de..956e252 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,9 @@ +2017-04-05 Pedro Alves + + * dis-asm.h (disassemble_info) : Now a + "const char *". + (next_disassembler_option): Constify. + 2017-04-04 H.J. Lu * elf/common.h (PT_GNU_MBIND_NUM): New. diff --git a/include/dis-asm.h b/include/dis-asm.h index f054450..2ed3d7e 100644 --- a/include/dis-asm.h +++ b/include/dis-asm.h @@ -210,7 +210,7 @@ typedef struct disassemble_info bfd_vma target2; /* Second target address for dref2 */ /* Command line options specific to the target disassembler. */ - char * disassembler_options; + const char *disassembler_options; /* If non-zero then try not disassemble beyond this address, even if there are values left in the buffer. This address is the address @@ -369,10 +369,10 @@ extern char *remove_whitespace_and_extra_commas (char *); extern int disassembler_options_cmp (const char *, const char *); /* A helper function for FOR_EACH_DISASSEMBLER_OPTION. */ -static inline char * -next_disassembler_option (char *options) +static inline const char * +next_disassembler_option (const char *options) { - char *opt = strchr (options, ','); + const char *opt = strchr (options, ','); if (opt != NULL) opt++; return opt; -- cgit v1.1