public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Cc: Binutils <binutils@sourceware.org>
Subject: [PATCH 01/18] -Wwrite-strings: Constify struct disassemble_info's disassembler_options field
Date: Tue, 04 Apr 2017 17:26:00 -0000	[thread overview]
Message-ID: <1491326751-16180-2-git-send-email-palves@redhat.com> (raw)
In-Reply-To: <1491326751-16180-1-git-send-email-palves@redhat.com>

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:
yyyy-mm-dd  Pedro Alves  <palves@redhat.com>

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

opcodes/ChangeLog:
yyyy-mm-dd  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:
yyyy-mm-dd  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/arm-tdep.c    | 2 +-
 gdb/disasm.c      | 2 +-
 gdb/i386-tdep.c   | 4 +---
 include/dis-asm.h | 8 ++++----
 opcodes/arc-dis.c | 4 ++--
 opcodes/arm-dis.c | 4 ++--
 opcodes/ppc-dis.c | 2 +-
 opcodes/vax-dis.c | 2 +-
 8 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index b3c3705..ade770e 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -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-"))
diff --git a/gdb/disasm.c b/gdb/disasm.c
index ab080e2..734db2b 100644
--- a/gdb/disasm.c
+++ b/gdb/disasm.c
@@ -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.  */
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index ec8b5d3..70bd47c 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -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);
 }
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;
diff --git a/opcodes/arc-dis.c b/opcodes/arc-dis.c
index 3afd253..4beca68 100644
--- a/opcodes/arc-dis.c
+++ b/opcodes/arc-dis.c
@@ -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;
diff --git a/opcodes/arm-dis.c b/opcodes/arm-dis.c
index e4f99b8..a3e53db 100644
--- a/opcodes/arm-dis.c
+++ b/opcodes/arm-dis.c
@@ -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)
     {
diff --git a/opcodes/ppc-dis.c b/opcodes/ppc-dis.c
index ee8016a..188e90a 100644
--- a/opcodes/ppc-dis.c
+++ b/opcodes/ppc-dis.c
@@ -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;
diff --git a/opcodes/vax-dis.c b/opcodes/vax-dis.c
index ff240e4..4642702 100644
--- a/opcodes/vax-dis.c
+++ b/opcodes/vax-dis.c
@@ -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:";
 
-- 
2.5.5

  reply	other threads:[~2017-04-04 17:25 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-04 17:25 [PATCH 00/18] gdb: Enable -Wwrite-strings (aka remove -Wno-write-strings) Pedro Alves
2017-04-04 17:26 ` Pedro Alves [this message]
2017-04-05  7:22   ` [PATCH 01/18] -Wwrite-strings: Constify struct disassemble_info's disassembler_options field Nick Clifton
2017-04-04 17:26 ` [PATCH 14/18] -Wwrite-strings: Add a PyArg_ParseTupleAndKeywords "const char *" overload Pedro Alves
2017-04-04 18:37   ` Sergio Durigan Junior
2017-04-05 12:58     ` Pedro Alves
2017-04-05 15:49       ` Sergio Durigan Junior
2017-04-04 17:26 ` [PATCH 08/18] -Wwrite-strings: Constify mi_cmd_argv_ftype's 'command' parameter Pedro Alves
2017-04-04 17:26 ` [PATCH 05/18] -Wwrite-strings: Constify warning_pre_print Pedro Alves
2017-04-04 17:26 ` [PATCH 02/18] -Wwrite-strings: Constify macroexp.c:init_shared_buffer Pedro Alves
2017-04-04 17:26 ` [PATCH 04/18] -Wwrite-strings: Constify shell_escape and plug make_command leak Pedro Alves
2017-04-04 17:26 ` [PATCH 06/18] -Wwrite-strings: Constify target_pid_to_str and target_thread_extra_thread_info Pedro Alves
2017-04-04 18:44   ` John Baldwin
2017-04-04 17:26 ` [PATCH 03/18] -Wwrite-strings: Don't initialize string command variables to empty string Pedro Alves
2017-04-04 17:26 ` [PATCH 16/18] -Wwrite-strings: Some constification in gdb/breakpoint.c Pedro Alves
2017-04-04 17:26 ` [PATCH 15/18] -Wwrite-strings: execute_command calls with string literals Pedro Alves
2017-04-05  7:13   ` Metzger, Markus T
2017-04-05 13:10     ` Pedro Alves
2017-04-04 17:26 ` [PATCH 07/18] -Wwrite-strings: Constify work break character arrays Pedro Alves
2017-04-05  8:46   ` Philipp Rudo
2017-04-05 13:17     ` Pedro Alves
2017-04-04 17:26 ` [PATCH 09/18] -Wwrite-strings: MI -info-os Pedro Alves
2017-04-04 17:31 ` [PATCH 10/18] -Wwrite-strings: gdbserver's 'port' parsing Pedro Alves
2017-04-04 17:32 ` [PATCH 18/18] -Wwrite-strings: Remove -Wno-write-strings Pedro Alves
2019-02-14 16:17   ` Thomas Schwinge
2017-04-04 17:32 ` [PATCH 13/18] -Wwrite-strings: Wrap PyGetSetDef for construction with string literals Pedro Alves
2017-04-04 18:40   ` Sergio Durigan Junior
2017-04-05 12:35     ` Pedro Alves
2017-04-05 15:48       ` Sergio Durigan Junior
2017-04-05  8:49   ` Philipp Rudo
2017-04-05 13:03     ` Pedro Alves
2017-04-04 17:32 ` [PATCH 11/18] -Wwrite-strings: gdbserver/win32-low.c and TARGET_WAITKIND_EXECD Pedro Alves
2017-04-04 17:33 ` [PATCH 12/18] -Wwrite-strings: More fix-old-Python-API wrappers Pedro Alves
2017-04-04 17:36 ` [PATCH 17/18] -Wwrite-strings: The Rest Pedro Alves
2017-04-04 18:44   ` John Baldwin
2017-04-05 12:59     ` Pedro Alves
2017-04-04 18:42 ` [PATCH 00/18] gdb: Enable -Wwrite-strings (aka remove -Wno-write-strings) Sergio Durigan Junior
2017-04-04 19:37 ` Simon Marchi
2017-04-05 18:05 ` Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1491326751-16180-2-git-send-email-palves@redhat.com \
    --to=palves@redhat.com \
    --cc=binutils@sourceware.org \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).