From b926417afaea99ed17663e06d6654d0048536017 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sat, 21 Apr 2018 16:16:27 -0600 Subject: Simple -Wshadow=local fixes This fixes all the straightforward -Wshadow=local warnings in gdb. A few standard approaches are used here: * Renaming an inner (or outer, but more commonly inner) variable; * Lowering a declaration to avoid a clash; * Moving a declaration into a more inner scope to avoid a clash, including the special case of moving a declaration into a loop header. I did not consider any of the changes in this patch to be particularly noteworthy, though of course they should all still be examined. gdb/ChangeLog 2018-10-04 Tom Tromey * ctf.c (SET_ARRAY_FIELD): Rename "u32". * p-valprint.c (pascal_val_print): Split inner "i" variable. * xtensa-tdep.c (xtensa_push_dummy_call): Declare "i" in loop header. * xstormy16-tdep.c (xstormy16_push_dummy_call): Declare "val" in more inner scope. * xcoffread.c (read_xcoff_symtab): Rename inner "symbol". * varobj.c (varobj_update): Rename inner "newobj", "type_changed". * valprint.c (generic_emit_char): Rename inner "buf". * valops.c (find_overload_match): Rename inner "temp". (value_struct_elt_for_reference): Declare "v" in more inner scope. * v850-tdep.c (v850_push_dummy_call): Rename "len". * unittests/array-view-selftests.c (run_tests): Rename inner "vec". * tui/tui-stack.c (tui_show_frame_info): Declare "i" in loop header. * tracepoint.c (merge_uploaded_trace_state_variables): Declare "tsv" in more inner scope. (print_one_static_tracepoint_marker): Rename inner "tuple_emitter". * tic6x-tdep.c (tic6x_analyze_prologue): Declare "inst" lower. (tic6x_push_dummy_call): Don't redeclare "addr". * target-float.c: Declare "dto" lower. * symtab.c (lookup_local_symbol): Rename inner "sym". (find_pc_sect_line): Rename inner "pc". * stack.c (print_frame): Don't redeclare "gdbarch". (return_command): Rename inner "gdbarch". * s390-tdep.c (s390_prologue_frame_unwind_cache): Renam inner "sp". * rust-lang.c (rust_internal_print_type): Declare "i" in loop header. * rs6000-tdep.c (ppc_process_record): Rename inner "addr". * riscv-tdep.c (riscv_push_dummy_call): Declare "info" in inner scope. * remote.c (remote_target::update_thread_list): Don't redeclare "tp". (remote_target::process_initial_stop_replies): Rename inner "thread". (remote_target::remote_parse_stop_reply): Don't redeclare "p". (remote_target::wait_as): Don't redeclare "stop_reply". (remote_target::get_thread_local_address): Rename inner "result". (remote_target::get_tib_address): Likewise. --- gdb/objfiles.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'gdb/objfiles.c') diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 4bffd20..a9b8fa7 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -773,15 +773,13 @@ static int objfile_relocate1 (struct objfile *objfile, const struct section_offsets *new_offsets) { - struct obj_section *s; struct section_offsets *delta = ((struct section_offsets *) alloca (SIZEOF_N_SECTION_OFFSETS (objfile->num_sections))); - int i; int something_changed = 0; - for (i = 0; i < objfile->num_sections; ++i) + for (int i = 0; i < objfile->num_sections; ++i) { delta->offsets[i] = ANOFFSET (new_offsets, i) - ANOFFSET (objfile->section_offsets, i); @@ -799,13 +797,12 @@ objfile_relocate1 (struct objfile *objfile, ALL_OBJFILE_FILETABS (objfile, cust, s) { struct linetable *l; - int i; /* First the line table. */ l = SYMTAB_LINETABLE (s); if (l) { - for (i = 0; i < l->nitems; ++i) + for (int i = 0; i < l->nitems; ++i) l->item[i].pc += ANOFFSET (delta, COMPUNIT_BLOCK_LINE_SECTION (cust)); @@ -821,7 +818,7 @@ objfile_relocate1 (struct objfile *objfile, addrmap_relocate (BLOCKVECTOR_MAP (bv), ANOFFSET (delta, block_line_section)); - for (i = 0; i < BLOCKVECTOR_NBLOCKS (bv); ++i) + for (int i = 0; i < BLOCKVECTOR_NBLOCKS (bv); ++i) { struct block *b; struct symbol *sym; @@ -872,6 +869,7 @@ objfile_relocate1 (struct objfile *objfile, get_objfile_pspace_data (objfile->pspace)->section_map_dirty = 1; /* Update the table in exec_ops, used to read memory. */ + struct obj_section *s; ALL_OBJFILE_OSECTIONS (objfile, s) { int idx = s - objfile->sections; -- cgit v1.1