]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
-Wwrite-strings: Constify struct disassemble_info's disassembler_options field
authorPedro Alves <palves@redhat.com>
Wed, 5 Apr 2017 18:21:33 +0000 (19:21 +0100)
committerPedro Alves <palves@redhat.com>
Wed, 5 Apr 2017 18:21:33 +0000 (19:21 +0100)
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  <palves@redhat.com>

* dis-asm.h (disassemble_info) <disassembler_options>: Now a
"const char *".
(next_disassembler_option): Constify.

opcodes/ChangeLog:
2017-04-05  Pedro Alves  <palves@redhat.com>

* 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  <palves@redhat.com>

* 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.

gdb/ChangeLog
gdb/arm-tdep.c
gdb/disasm.c
gdb/i386-tdep.c
include/ChangeLog
include/dis-asm.h
opcodes/ChangeLog
opcodes/arc-dis.c
opcodes/arm-dis.c
opcodes/ppc-dis.c
opcodes/vax-dis.c

index 4141beb64b7b758423d22e2dc78565147ae57df8..1d0270cf9247e07791924dab7fefe4cb68801544 100644 (file)
@@ -1,3 +1,9 @@
+2017-04-05  Pedro Alves  <palves@redhat.com>
+
+       * 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.
+
 2017-04-05  Sergio Durigan Junior  <sergiodj@redhat.com>
 
        PR gdb/21352
index b3c3705c78eaccbd2e4595998732312c3d015d44..ade770ea0162cf69a76880e758d27268f77eb4aa 100644 (file)
@@ -8562,7 +8562,7 @@ show_disassembly_style_sfunc (struct ui_file *file, int from_tty,
   char *options = get_disassembler_options (gdbarch);
   const char *style = "";
   int len = 0;
-  char *opt;
+  const char *opt;
 
   FOR_EACH_DISASSEMBLER_OPTION (opt, options)
     if (CONST_STRNEQ (opt, "reg-names-"))
index ab080e2690e74b17c2447374dda7e921af0496c3..734db2b1c8296b284b56c7f9a46a92c3ea10bf05 100644 (file)
@@ -930,7 +930,7 @@ set_disassembler_options (char *prospective_options)
   char **disassembler_options = gdbarch_disassembler_options (gdbarch);
   const disasm_options_t *valid_options;
   char *options = remove_whitespace_and_extra_commas (prospective_options);
-  char *opt;
+  const char *opt;
 
   /* Allow all architectures, even ones that do not support 'set disassembler',
      to reset their disassembler options to NULL.  */
index ec8b5d3b1bc5e3f5781eaaa6aa5c2e76251504a7..70bd47ce3000a7fbdb79dc097bbd76dba0a60d41 100644 (file)
@@ -4009,9 +4009,7 @@ i386_print_insn (bfd_vma pc, struct disassemble_info *info)
   gdb_assert (disassembly_flavor == att_flavor
              || disassembly_flavor == intel_flavor);
 
-  /* FIXME: kettenis/20020915: Until disassembler_options is properly
-     constified, cast to prevent a compiler warning.  */
-  info->disassembler_options = (char *) disassembly_flavor;
+  info->disassembler_options = disassembly_flavor;
 
   return print_insn_i386 (pc, info);
 }
index fa0f3deb7224489e6af6983b8837f0f8e89a2332..956e25261264f552f84a29fc92a6b21c74d40487 100644 (file)
@@ -1,3 +1,9 @@
+2017-04-05  Pedro Alves  <palves@redhat.com>
+
+       * dis-asm.h (disassemble_info) <disassembler_options>: Now a
+       "const char *".
+       (next_disassembler_option): Constify.
+
 2017-04-04  H.J. Lu  <hongjiu.lu@intel.com>
 
        * elf/common.h (PT_GNU_MBIND_NUM): New.
index f0544509d0c1beb96d4f6791932029d011cfda1d..2ed3d7ec6caecd96a40133502f32a7e7d7061395 100644 (file)
@@ -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;
index ce6ee4080f9987b70fae2cc029e649085bd9a872..2889f53420a921f74bb4b5c39cb29a9e8cd6a26a 100644 (file)
@@ -1,3 +1,10 @@
+2017-04-05  Pedro Alves  <palves@redhat.com>
+
+       * 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.
+
 2017-04-03  Palmer Dabbelt  <palmer@dabbelt.com>
 
        * riscv-dis.c (riscv_disassemble_insn): Change "_gp" to
index 3afd2533c860b62027e808770b237e50ae455092..4beca689c397c42ee33c13da3024927d13f3b7d3 100644 (file)
@@ -733,7 +733,7 @@ operand_iterator_next (struct arc_operand_iterator *iter,
 /* Helper for parsing the options.  */
 
 static void
-parse_option (char *option)
+parse_option (const char *option)
 {
   if (CONST_STRNEQ (option, "dsp"))
     add_to_decodelist (DSP, NONE);
@@ -772,7 +772,7 @@ parse_option (char *option)
 /* Go over the options list and parse it.  */
 
 static void
-parse_disassembler_options (char *options)
+parse_disassembler_options (const char *options)
 {
   if (options == NULL)
     return;
index e4f99b823518c697aa2f896e9d8f7b0caa62664e..a3e53db01bc6366d808c4fe4817bc3c422bae199 100644 (file)
@@ -6101,9 +6101,9 @@ arm_symbol_is_valid (asymbol * sym,
 /* Parse the string of disassembler options.  */
 
 static void
-parse_arm_disassembler_options (char *options)
+parse_arm_disassembler_options (const char *options)
 {
-  char *opt;
+  const char *opt;
 
   FOR_EACH_DISASSEMBLER_OPTION (opt, options)
     {
index ee8016a7842abd5128161d9fae62e8cb5184c10e..188e90aaafa1cba7519ee7b5adf1340d6c80754b 100644 (file)
@@ -344,7 +344,7 @@ powerpc_init_dialect (struct disassemble_info *info)
       break;
     }
 
-  char *opt;
+  const char *opt;
   FOR_EACH_DISASSEMBLER_OPTION (opt, info->disassembler_options)
     {
       ppc_cpu_t new_cpu = 0;
index ff240e4c2a7134af58f91d3a9f6fd0b58308518d..4642702787d38534a805a1f3bf2fbdad7b0e722c 100644 (file)
@@ -117,7 +117,7 @@ static bfd_vma *     entry_addr = NULL;
    there's no symbol table.  Returns TRUE upon success, FALSE otherwise.  */
 
 static bfd_boolean
-parse_disassembler_options (char * options)
+parse_disassembler_options (const char *options)
 {
   const char * entry_switch = "entry:";