More char constification
authorPedro Alves <palves@redhat.com>
Tue, 13 Oct 2015 18:40:50 +0000 (19:40 +0100)
committerPedro Alves <palves@redhat.com>
Tue, 13 Oct 2015 18:40:50 +0000 (19:40 +0100)
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.

14 files changed:
gdb/ChangeLog
gdb/ada-lang.c
gdb/ada-typeprint.c
gdb/c-varobj.c
gdb/cli/cli-setshow.c
gdb/common/gdb_vecs.c
gdb/dwarf2read.c
gdb/gnu-v3-abi.c
gdb/go-lang.c
gdb/jv-typeprint.c
gdb/ser-tcp.c
gdb/symfile.c
gdb/symtab.c
gdb/tui/tui-io.c

index 84eb37c0ffb5d4a2e53aacbdc4324291e3bfd52a..fddacfe40a61fb5d2f8af559cf014142241b1d39 100644 (file)
@@ -1,3 +1,20 @@
+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.
index 383db9963cec204ac37da44189334f1e597a495a..fff48623b180c8275f78054210452e47230a7644 100644 (file)
@@ -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
index 11fdc7090be67fa6f7450682371fcaf0516c5d35..4164bb2c8442b1f72fa4b372955e2c7e0c8a7db3 100644 (file)
@@ -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;
index 59d8b0f781a3c97f942d30422d5cf3cbf1a0a4f9..b39a113aade45eedf2fe3137f8aedd06ddbd1e76 100644 (file)
@@ -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 
index 9439f48fb1a3bf87791a6a29da9d4ca97d70de93..1ffb80b4a65e87e3f52cbb7f94fbf07eb7258e71 100644 (file)
@@ -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);
          }
index 63766db00115ab75bce5fb5179f4f0cfa7902c25..f8c34147222b726dc46e1bb1788a89a8f23a4585 100644 (file)
@@ -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)
index ddd4a4c932ee6839ec5cf93b1c54cfcdcbfa5cb2..0c45d294a4e9c1adcf511c0aa3bdcb58a72f1fda 100644 (file)
@@ -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)
index b962cd3f95d11bfae3d8407d34ac0d676de01bc4..09e085b9fc5aadc88254d75f980205d8064a281f 100644 (file)
@@ -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)
index f6d731be8285cad19226004c7acb4cc8dae4cff8..6e70c893403985733ebe2d828e6c498bbaeb44f4 100644 (file)
@@ -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;
 
index 441f313f5705f35c85c8d564b6469730b0ec7851..5bba39c81561870730f8a08527d71af955b7f80d 100644 (file)
@@ -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);
index 485ed6c082d78df0f9f49e7e34f563f592a55a80..ce40b6160148ac776572f8f2aff498d04ca56d1f 100644 (file)
@@ -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;
index 682e3cab6dc7d6665d93c63c6447f05a58412f0e..55a9f5c516cc2ed67d14db67c5a606a38f532797 100644 (file)
@@ -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)
index c95b651f69a09d9579be498a008d6fa04de459f9..b0a16b6e97d8b7cf32a196577973b4f45b6df395 100644 (file)
@@ -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));
 
index 6f81f0980ff73788fafd5f502b2fcd9dc46d55f0..253d7e97b4a30672d481f52e0007363de7d3b4da 100644 (file)
@@ -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
This page took 0.053483 seconds and 4 git commands to generate.