This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] More char constification


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e6a959d68b8181c816851dcfc91ae0b2b9296df3

commit e6a959d68b8181c816851dcfc91ae0b2b9296df3
Author: Pedro Alves <palves@redhat.com>
Date:   Tue Oct 13 19:40:50 2015 +0100

    More char constification
    
    Trivial constifications flagged by G++.  E.g.:
    
     src/gdb/c-varobj.c: In function â??void c_describe_child(const varobj*, int, char**, value**, type**, char**)â??:
     src/gdb/c-varobj.c:373:33: error: invalid conversion from â??const char*â?? to â??char*â?? [-fpermissive]
        char *join = was_ptr ? "->" : ".";
    				  ^
    
    gdb/ChangeLog:
    2015-10-13  Pedro Alves  <palves@redhat.com>
    
    	* ada-lang.c (ada_enum_name): Constify local.
    	* ada-typeprint.c (print_range_bound): Constify locals.
    	* c-varobj.c (c_describe_child): Likewise.
    	* cli/cli-setshow.c (do_set_command): Likewise.
    	* gdb_vecs.c (delim_string_to_char_ptr_vec_append): Likewise.
    	* dwarf2read.c (find_file_and_directory): Likewise.
    	(anonymous_struct_prefix, dwarf2_name): Likewise.
    	* gnu-v3-abi.c (gnuv3_rtti_type): Likewise.
    	* go-lang.c (unpack_mangled_go_symbol): Likewise.
    	* jv-typeprint.c (java_type_print_base): Likewise.
    	* ser-tcp.c (net_open): Likewise.
    	* symfile.c (deduce_language_from_filename): Likewise.
    	* symtab.c (gdb_mangle_name): Likewise.
    	* tui/tui-io.c (tui_redisplay_readline): Likewise.

Diff:
---
 gdb/ChangeLog         | 17 +++++++++++++++++
 gdb/ada-lang.c        |  2 +-
 gdb/ada-typeprint.c   |  8 ++++----
 gdb/c-varobj.c        |  6 +++---
 gdb/cli/cli-setshow.c |  2 +-
 gdb/common/gdb_vecs.c |  3 ++-
 gdb/dwarf2read.c      |  6 +++---
 gdb/gnu-v3-abi.c      |  2 +-
 gdb/go-lang.c         |  4 ++--
 gdb/jv-typeprint.c    |  3 ++-
 gdb/ser-tcp.c         |  3 ++-
 gdb/symfile.c         |  2 +-
 gdb/symtab.c          |  4 ++--
 gdb/tui/tui-io.c      |  2 +-
 14 files changed, 42 insertions(+), 22 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 84eb37c..fddacfe 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,22 @@
 2015-10-13  Pedro Alves  <palves@redhat.com>
 
+	* ada-lang.c (ada_enum_name): Constify local.
+	* ada-typeprint.c (print_range_bound): Constify locals.
+	* c-varobj.c (c_describe_child): Likewise.
+	* cli/cli-setshow.c (do_set_command): Likewise.
+	* gdb_vecs.c (delim_string_to_char_ptr_vec_append): Likewise.
+	* dwarf2read.c (find_file_and_directory): Likewise.
+	(anonymous_struct_prefix, dwarf2_name): Likewise.
+	* gnu-v3-abi.c (gnuv3_rtti_type): Likewise.
+	* go-lang.c (unpack_mangled_go_symbol): Likewise.
+	* jv-typeprint.c (java_type_print_base): Likewise.
+	* ser-tcp.c (net_open): Likewise.
+	* symfile.c (deduce_language_from_filename): Likewise.
+	* symtab.c (gdb_mangle_name): Likewise.
+	* tui/tui-io.c (tui_redisplay_readline): Likewise.
+
+2015-10-13  Pedro Alves  <palves@redhat.com>
+
 	* infrun.c (restore_execution_direction): New function.
 	(fetch_inferior_event): Use it instead of
 	make_cleanup_restore_integer.
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 383db99..fff4862 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -9430,7 +9430,7 @@ ada_enum_name (const char *name)
 {
   static char *result;
   static size_t result_len = 0;
-  char *tmp;
+  const char *tmp;
 
   /* First, unqualify the enumeration name:
      1. Search for the last '.' character.  If we find one, then skip
diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c
index 11fdc70..4164bb2 100644
--- a/gdb/ada-typeprint.c
+++ b/gdb/ada-typeprint.c
@@ -203,7 +203,7 @@ print_range (struct type *type, struct ui_file *stream,
    set *N past the bound and its delimiter, if any.  */
 
 static void
-print_range_bound (struct type *type, char *bounds, int *n,
+print_range_bound (struct type *type, const char *bounds, int *n,
 		   struct ui_file *stream)
 {
   LONGEST B;
@@ -230,8 +230,8 @@ print_range_bound (struct type *type, char *bounds, int *n,
   else
     {
       int bound_len;
-      char *bound = bounds + *n;
-      char *pend;
+      const char *bound = bounds + *n;
+      const char *pend;
 
       pend = strstr (bound, "__");
       if (pend == NULL)
@@ -300,7 +300,7 @@ print_range_type (struct type *raw_type, struct ui_file *stream,
   else
     {
       int prefix_len = subtype_info - name;
-      char *bounds_str;
+      const char *bounds_str;
       int n;
 
       subtype_info += 5;
diff --git a/gdb/c-varobj.c b/gdb/c-varobj.c
index 59d8b0f..b39a113 100644
--- a/gdb/c-varobj.c
+++ b/gdb/c-varobj.c
@@ -370,7 +370,7 @@ c_describe_child (const struct varobj *parent, int index,
 
 	    if (cfull_expression)
 	      {
-		char *join = was_ptr ? "->" : ".";
+		const char *join = was_ptr ? "->" : ".";
 
 		*cfull_expression = xstrprintf ("(%s)%s%s", parent_expression,
 						join, field_name);
@@ -741,7 +741,7 @@ cplus_describe_child (const struct varobj *parent, int index,
   if (TYPE_CODE (type) == TYPE_CODE_STRUCT
       || TYPE_CODE (type) == TYPE_CODE_UNION)
     {
-      char *join = was_ptr ? "->" : ".";
+      const char *join = was_ptr ? "->" : ".";
 
       if (CPLUS_FAKE_CHILD (parent))
 	{
@@ -825,7 +825,7 @@ cplus_describe_child (const struct varobj *parent, int index,
 
 	  if (cfull_expression)
 	    {
-	      char *ptr = was_ptr ? "*" : "";
+	      const char *ptr = was_ptr ? "*" : "";
 
 	      /* Cast the parent to the base' type.  Note that in gdb,
 		 expression like 
diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c
index 9439f48fb..1ffb80b 100644
--- a/gdb/cli/cli-setshow.c
+++ b/gdb/cli/cli-setshow.c
@@ -523,7 +523,7 @@ do_set_command (const char *arg, int from_tty, struct cmd_list_element *c)
 	  break;
 	case var_boolean:
 	  {
-	    char *opt = *(int *) c->var ? "on" : "off";
+	    const char *opt = *(int *) c->var ? "on" : "off";
 
 	    observer_notify_command_param_changed (name, opt);
 	  }
diff --git a/gdb/common/gdb_vecs.c b/gdb/common/gdb_vecs.c
index 63766db..f8c3414 100644
--- a/gdb/common/gdb_vecs.c
+++ b/gdb/common/gdb_vecs.c
@@ -49,7 +49,8 @@ delim_string_to_char_ptr_vec_append (VEC (char_ptr) **vecp,
   do
     {
       size_t this_len;
-      char *next_field, *this_field;
+      const char *next_field;
+      char *this_field;
 
       next_field = strchr (str, delimiter);
       if (next_field == NULL)
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index ddd4a4c..0c45d29 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -9074,7 +9074,7 @@ find_file_and_directory (struct die_info *die, struct dwarf2_cu *cu,
     {
       /* Irix 6.2 native cc prepends <machine>.: to the compilation
 	 directory, get rid of it.  */
-      char *cp = strchr (*comp_dir, ':');
+      const char *cp = strchr (*comp_dir, ':');
 
       if (cp && cp != *comp_dir && cp[-1] == '.' && cp[1] == '/')
 	*comp_dir = cp + 1;
@@ -19239,7 +19239,7 @@ static char *
 anonymous_struct_prefix (struct die_info *die, struct dwarf2_cu *cu)
 {
   struct attribute *attr;
-  char *base;
+  const char *base;
 
   if (die->tag != DW_TAG_class_type && die->tag != DW_TAG_interface_type
       && die->tag != DW_TAG_structure_type && die->tag != DW_TAG_union_type)
@@ -19621,7 +19621,7 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu)
 
 	  if (demangled)
 	    {
-	      char *base;
+	      const char *base;
 
 	      /* FIXME: we already did this for the partial symbol... */
 	      DW_STRING (attr)
diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c
index b962cd3..09e085b 100644
--- a/gdb/gnu-v3-abi.c
+++ b/gdb/gnu-v3-abi.c
@@ -296,7 +296,7 @@ gnuv3_rtti_type (struct value *value,
   const char *class_name;
   struct type *run_time_type;
   LONGEST offset_to_top;
-  char *atsign;
+  const char *atsign;
 
   /* We only have RTTI for class objects.  */
   if (TYPE_CODE (values_type) != TYPE_CODE_STRUCT)
diff --git a/gdb/go-lang.c b/gdb/go-lang.c
index f6d731b..6e70c89 100644
--- a/gdb/go-lang.c
+++ b/gdb/go-lang.c
@@ -195,9 +195,9 @@ unpack_mangled_go_symbol (const char *mangled_name,
   /* Pointer to "N" if valid "N<digit(s)>_" found.  */
   char *method_type;
   /* Pointer to the first '.'.  */
-  char *first_dot;
+  const char *first_dot;
   /* Pointer to the last '.'.  */
-  char *last_dot;
+  const char *last_dot;
   /* Non-zero if we saw a pointer indicator.  */
   int saw_pointer;
 
diff --git a/gdb/jv-typeprint.c b/gdb/jv-typeprint.c
index 441f313..5bba39c 100644
--- a/gdb/jv-typeprint.c
+++ b/gdb/jv-typeprint.c
@@ -223,7 +223,8 @@ java_type_print_base (struct type *type, struct ui_file *stream, int show,
 	      for (j = 0; j < n_overloads; j++)
 		{
 		  const char *real_physname;
-		  char *physname, *p;
+		  const char *p;
+		  char *physname;
 		  int is_full_physname_constructor;
 
 		  real_physname = TYPE_FN_FIELD_PHYSNAME (f, j);
diff --git a/gdb/ser-tcp.c b/gdb/ser-tcp.c
index 485ed6c..ce40b61 100644
--- a/gdb/ser-tcp.c
+++ b/gdb/ser-tcp.c
@@ -155,7 +155,8 @@ wait_for_connect (struct serial *scb, unsigned int *polls)
 int
 net_open (struct serial *scb, const char *name)
 {
-  char *port_str, hostname[100];
+  char hostname[100];
+  const char *port_str;
   int n, port, tmp;
   int use_udp;
   struct hostent *hostent;
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 682e3ca..55a9f5c 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2881,7 +2881,7 @@ enum language
 deduce_language_from_filename (const char *filename)
 {
   int i;
-  char *cp;
+  const char *cp;
 
   if (filename != NULL)
     if ((cp = strrchr (filename, '.')) != NULL)
diff --git a/gdb/symtab.c b/gdb/symtab.c
index c95b651..b0a16b6 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -515,8 +515,8 @@ gdb_mangle_name (struct type *type, int method_id, int signature_id)
   int is_constructor;
   int is_destructor = is_destructor_name (physname);
   /* Need a new type prefix.  */
-  char *const_prefix = method->is_const ? "C" : "";
-  char *volatile_prefix = method->is_volatile ? "V" : "";
+  const char *const_prefix = method->is_const ? "C" : "";
+  const char *volatile_prefix = method->is_volatile ? "V" : "";
   char buf[20];
   int len = (newname == NULL ? 0 : strlen (newname));
 
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index 6f81f09..253d7e9 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -203,7 +203,7 @@ tui_redisplay_readline (void)
   int c_line;
   int in;
   WINDOW *w;
-  char *prompt;
+  const char *prompt;
   int start_line;
 
   /* Detect when we temporarily left SingleKey and now the readline


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]