修订版 | e6a959d68b8181c816851dcfc91ae0b2b9296df3 (tree) |
---|---|
时间 | 2015-10-14 03:40:50 |
作者 | Pedro Alves <palves@redh...> |
Commiter | Pedro Alves |
More char constification
Trivial constifications flagged by G++. E.g.:
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.
@@ -1,5 +1,22 @@ | ||
1 | 1 | 2015-10-13 Pedro Alves <palves@redhat.com> |
2 | 2 | |
3 | + * ada-lang.c (ada_enum_name): Constify local. | |
4 | + * ada-typeprint.c (print_range_bound): Constify locals. | |
5 | + * c-varobj.c (c_describe_child): Likewise. | |
6 | + * cli/cli-setshow.c (do_set_command): Likewise. | |
7 | + * gdb_vecs.c (delim_string_to_char_ptr_vec_append): Likewise. | |
8 | + * dwarf2read.c (find_file_and_directory): Likewise. | |
9 | + (anonymous_struct_prefix, dwarf2_name): Likewise. | |
10 | + * gnu-v3-abi.c (gnuv3_rtti_type): Likewise. | |
11 | + * go-lang.c (unpack_mangled_go_symbol): Likewise. | |
12 | + * jv-typeprint.c (java_type_print_base): Likewise. | |
13 | + * ser-tcp.c (net_open): Likewise. | |
14 | + * symfile.c (deduce_language_from_filename): Likewise. | |
15 | + * symtab.c (gdb_mangle_name): Likewise. | |
16 | + * tui/tui-io.c (tui_redisplay_readline): Likewise. | |
17 | + | |
18 | +2015-10-13 Pedro Alves <palves@redhat.com> | |
19 | + | |
3 | 20 | * infrun.c (restore_execution_direction): New function. |
4 | 21 | (fetch_inferior_event): Use it instead of |
5 | 22 | make_cleanup_restore_integer. |
@@ -9430,7 +9430,7 @@ ada_enum_name (const char *name) | ||
9430 | 9430 | { |
9431 | 9431 | static char *result; |
9432 | 9432 | static size_t result_len = 0; |
9433 | - char *tmp; | |
9433 | + const char *tmp; | |
9434 | 9434 | |
9435 | 9435 | /* First, unqualify the enumeration name: |
9436 | 9436 | 1. Search for the last '.' character. If we find one, then skip |
@@ -203,7 +203,7 @@ print_range (struct type *type, struct ui_file *stream, | ||
203 | 203 | set *N past the bound and its delimiter, if any. */ |
204 | 204 | |
205 | 205 | static void |
206 | -print_range_bound (struct type *type, char *bounds, int *n, | |
206 | +print_range_bound (struct type *type, const char *bounds, int *n, | |
207 | 207 | struct ui_file *stream) |
208 | 208 | { |
209 | 209 | LONGEST B; |
@@ -230,8 +230,8 @@ print_range_bound (struct type *type, char *bounds, int *n, | ||
230 | 230 | else |
231 | 231 | { |
232 | 232 | int bound_len; |
233 | - char *bound = bounds + *n; | |
234 | - char *pend; | |
233 | + const char *bound = bounds + *n; | |
234 | + const char *pend; | |
235 | 235 | |
236 | 236 | pend = strstr (bound, "__"); |
237 | 237 | if (pend == NULL) |
@@ -300,7 +300,7 @@ print_range_type (struct type *raw_type, struct ui_file *stream, | ||
300 | 300 | else |
301 | 301 | { |
302 | 302 | int prefix_len = subtype_info - name; |
303 | - char *bounds_str; | |
303 | + const char *bounds_str; | |
304 | 304 | int n; |
305 | 305 | |
306 | 306 | subtype_info += 5; |
@@ -370,7 +370,7 @@ c_describe_child (const struct varobj *parent, int index, | ||
370 | 370 | |
371 | 371 | if (cfull_expression) |
372 | 372 | { |
373 | - char *join = was_ptr ? "->" : "."; | |
373 | + const char *join = was_ptr ? "->" : "."; | |
374 | 374 | |
375 | 375 | *cfull_expression = xstrprintf ("(%s)%s%s", parent_expression, |
376 | 376 | join, field_name); |
@@ -741,7 +741,7 @@ cplus_describe_child (const struct varobj *parent, int index, | ||
741 | 741 | if (TYPE_CODE (type) == TYPE_CODE_STRUCT |
742 | 742 | || TYPE_CODE (type) == TYPE_CODE_UNION) |
743 | 743 | { |
744 | - char *join = was_ptr ? "->" : "."; | |
744 | + const char *join = was_ptr ? "->" : "."; | |
745 | 745 | |
746 | 746 | if (CPLUS_FAKE_CHILD (parent)) |
747 | 747 | { |
@@ -825,7 +825,7 @@ cplus_describe_child (const struct varobj *parent, int index, | ||
825 | 825 | |
826 | 826 | if (cfull_expression) |
827 | 827 | { |
828 | - char *ptr = was_ptr ? "*" : ""; | |
828 | + const char *ptr = was_ptr ? "*" : ""; | |
829 | 829 | |
830 | 830 | /* Cast the parent to the base' type. Note that in gdb, |
831 | 831 | expression like |
@@ -523,7 +523,7 @@ do_set_command (const char *arg, int from_tty, struct cmd_list_element *c) | ||
523 | 523 | break; |
524 | 524 | case var_boolean: |
525 | 525 | { |
526 | - char *opt = *(int *) c->var ? "on" : "off"; | |
526 | + const char *opt = *(int *) c->var ? "on" : "off"; | |
527 | 527 | |
528 | 528 | observer_notify_command_param_changed (name, opt); |
529 | 529 | } |
@@ -49,7 +49,8 @@ delim_string_to_char_ptr_vec_append (VEC (char_ptr) **vecp, | ||
49 | 49 | do |
50 | 50 | { |
51 | 51 | size_t this_len; |
52 | - char *next_field, *this_field; | |
52 | + const char *next_field; | |
53 | + char *this_field; | |
53 | 54 | |
54 | 55 | next_field = strchr (str, delimiter); |
55 | 56 | if (next_field == NULL) |
@@ -9074,7 +9074,7 @@ find_file_and_directory (struct die_info *die, struct dwarf2_cu *cu, | ||
9074 | 9074 | { |
9075 | 9075 | /* Irix 6.2 native cc prepends <machine>.: to the compilation |
9076 | 9076 | directory, get rid of it. */ |
9077 | - char *cp = strchr (*comp_dir, ':'); | |
9077 | + const char *cp = strchr (*comp_dir, ':'); | |
9078 | 9078 | |
9079 | 9079 | if (cp && cp != *comp_dir && cp[-1] == '.' && cp[1] == '/') |
9080 | 9080 | *comp_dir = cp + 1; |
@@ -19239,7 +19239,7 @@ static char * | ||
19239 | 19239 | anonymous_struct_prefix (struct die_info *die, struct dwarf2_cu *cu) |
19240 | 19240 | { |
19241 | 19241 | struct attribute *attr; |
19242 | - char *base; | |
19242 | + const char *base; | |
19243 | 19243 | |
19244 | 19244 | if (die->tag != DW_TAG_class_type && die->tag != DW_TAG_interface_type |
19245 | 19245 | && 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) | ||
19621 | 19621 | |
19622 | 19622 | if (demangled) |
19623 | 19623 | { |
19624 | - char *base; | |
19624 | + const char *base; | |
19625 | 19625 | |
19626 | 19626 | /* FIXME: we already did this for the partial symbol... */ |
19627 | 19627 | DW_STRING (attr) |
@@ -296,7 +296,7 @@ gnuv3_rtti_type (struct value *value, | ||
296 | 296 | const char *class_name; |
297 | 297 | struct type *run_time_type; |
298 | 298 | LONGEST offset_to_top; |
299 | - char *atsign; | |
299 | + const char *atsign; | |
300 | 300 | |
301 | 301 | /* We only have RTTI for class objects. */ |
302 | 302 | if (TYPE_CODE (values_type) != TYPE_CODE_STRUCT) |
@@ -195,9 +195,9 @@ unpack_mangled_go_symbol (const char *mangled_name, | ||
195 | 195 | /* Pointer to "N" if valid "N<digit(s)>_" found. */ |
196 | 196 | char *method_type; |
197 | 197 | /* Pointer to the first '.'. */ |
198 | - char *first_dot; | |
198 | + const char *first_dot; | |
199 | 199 | /* Pointer to the last '.'. */ |
200 | - char *last_dot; | |
200 | + const char *last_dot; | |
201 | 201 | /* Non-zero if we saw a pointer indicator. */ |
202 | 202 | int saw_pointer; |
203 | 203 |
@@ -223,7 +223,8 @@ java_type_print_base (struct type *type, struct ui_file *stream, int show, | ||
223 | 223 | for (j = 0; j < n_overloads; j++) |
224 | 224 | { |
225 | 225 | const char *real_physname; |
226 | - char *physname, *p; | |
226 | + const char *p; | |
227 | + char *physname; | |
227 | 228 | int is_full_physname_constructor; |
228 | 229 | |
229 | 230 | real_physname = TYPE_FN_FIELD_PHYSNAME (f, j); |
@@ -155,7 +155,8 @@ wait_for_connect (struct serial *scb, unsigned int *polls) | ||
155 | 155 | int |
156 | 156 | net_open (struct serial *scb, const char *name) |
157 | 157 | { |
158 | - char *port_str, hostname[100]; | |
158 | + char hostname[100]; | |
159 | + const char *port_str; | |
159 | 160 | int n, port, tmp; |
160 | 161 | int use_udp; |
161 | 162 | struct hostent *hostent; |
@@ -2881,7 +2881,7 @@ enum language | ||
2881 | 2881 | deduce_language_from_filename (const char *filename) |
2882 | 2882 | { |
2883 | 2883 | int i; |
2884 | - char *cp; | |
2884 | + const char *cp; | |
2885 | 2885 | |
2886 | 2886 | if (filename != NULL) |
2887 | 2887 | if ((cp = strrchr (filename, '.')) != NULL) |
@@ -515,8 +515,8 @@ gdb_mangle_name (struct type *type, int method_id, int signature_id) | ||
515 | 515 | int is_constructor; |
516 | 516 | int is_destructor = is_destructor_name (physname); |
517 | 517 | /* Need a new type prefix. */ |
518 | - char *const_prefix = method->is_const ? "C" : ""; | |
519 | - char *volatile_prefix = method->is_volatile ? "V" : ""; | |
518 | + const char *const_prefix = method->is_const ? "C" : ""; | |
519 | + const char *volatile_prefix = method->is_volatile ? "V" : ""; | |
520 | 520 | char buf[20]; |
521 | 521 | int len = (newname == NULL ? 0 : strlen (newname)); |
522 | 522 |
@@ -203,7 +203,7 @@ tui_redisplay_readline (void) | ||
203 | 203 | int c_line; |
204 | 204 | int in; |
205 | 205 | WINDOW *w; |
206 | - char *prompt; | |
206 | + const char *prompt; | |
207 | 207 | int start_line; |
208 | 208 | |
209 | 209 | /* Detect when we temporarily left SingleKey and now the readline |