From patchwork Mon Jun 6 21:33:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 12818 Received: (qmail 120003 invoked by alias); 6 Jun 2016 21:34:03 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 119944 invoked by uid 89); 6 Jun 2016 21:34:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.8 required=5.0 tests=AWL, BAYES_00, FSL_HELO_HOME, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=no version=3.3.2 spammy=922, 6, 9226, fp, 59666 X-HELO: gproxy9-pub.mail.unifiedlayer.com Received: from gproxy9-pub.mail.unifiedlayer.com (HELO gproxy9-pub.mail.unifiedlayer.com) (69.89.20.122) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with SMTP; Mon, 06 Jun 2016 21:33:46 +0000 Received: (qmail 20592 invoked by uid 0); 6 Jun 2016 21:33:45 -0000 Received: from unknown (HELO CMOut01) (10.0.90.82) by gproxy9.mail.unifiedlayer.com with SMTP; 6 Jun 2016 21:33:45 -0000 Received: from box522.bluehost.com ([74.220.219.122]) by CMOut01 with id 3ZZg1t01d2f2jeq01ZZjqe; Mon, 06 Jun 2016 15:33:43 -0600 X-Authority-Analysis: v=2.1 cv=OPe0g0qB c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=PnD2wP_eR3oA:10 a=-N9Dh3nx2ZYA:10 a=pD_ry4oyNxEA:10 a=zstS-IiYAAAA:8 a=Vwg1E-SCkLvC5y_YWt4A:9 a=7yh8K6bdJ59pih9X:21 a=Ord3II5e_DaPYOKf:21 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from [65.128.48.199] (port=46482 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.86_2) (envelope-from ) id 1bA29V-0006Xd-QL; Mon, 06 Jun 2016 15:33:42 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 5/6] Remove unused variables Date: Mon, 6 Jun 2016 15:33:31 -0600 Message-Id: <1465248812-23902-6-git-send-email-tom@tromey.com> In-Reply-To: <1465248812-23902-1-git-send-email-tom@tromey.com> References: <1465248812-23902-1-git-send-email-tom@tromey.com> X-Identified-User: {36111:box522.bluehost.com:elynrobi:tromey.com} {sentby:smtp auth 65.128.48.199 authed with tom+tromey.com} X-Exim-ID: 1bA29V-0006Xd-QL X-Source-Sender: (bapiya.Home) [65.128.48.199]:46482 X-Source-Auth: tom+tromey.com X-Email-Count: 0 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== This patch removes set-but-unused variables. This holds all the removals I consider to be simple and relatively uncontroversial. 2016-06-06 Tom Tromey * mips-tdep.c (micromips_scan_prologue): Remove "frame_addr". (mips_o32_push_dummy_call): Remove "stack_used_p". * aarch64-tdep.c (aarch64_record_data_proc_imm): Remove "insn_bit28". * rust-lang.c (rust_print_type): Remove "len". * rust-exp.y (super_name): Remove "current_len". * python/py-framefilter.c (py_print_type): Remove "type". * mdebugread.c (parse_partial_symbols): Remove "past_first_source_file". : Remove "valu", "first_so_symnum", "prev_textlow_not_set". * m2-valprint.c (m2_print_unbounded_array): Remove "content_type". (m2_val_print): Remove "i". * linespec.c (unexpected_linespec_error): Remove "cleanup". * f-valprint.c (f_val_print): Remove "i". * elfread.c (elf_symtab_read): Remove "offset". * dwarf2-frame.c (dwarf2_fetch_cfa_info): Remove "addr_size". --- gdb/ChangeLog | 20 ++++++++++++++++++++ gdb/aarch64-tdep.c | 3 +-- gdb/dwarf2-frame.c | 2 -- gdb/elfread.c | 3 --- gdb/f-valprint.c | 5 ++--- gdb/linespec.c | 3 +-- gdb/m2-valprint.c | 4 ---- gdb/mdebugread.c | 18 +----------------- gdb/mips-tdep.c | 13 +------------ gdb/python/py-framefilter.c | 2 -- gdb/rust-exp.y | 4 +--- gdb/rust-lang.c | 3 +-- 12 files changed, 28 insertions(+), 52 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index b164911..eec280d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,25 @@ 2016-06-06 Tom Tromey + * mips-tdep.c (micromips_scan_prologue): Remove "frame_addr". + (mips_o32_push_dummy_call): Remove "stack_used_p". + * aarch64-tdep.c (aarch64_record_data_proc_imm): Remove + "insn_bit28". + * rust-lang.c (rust_print_type): Remove "len". + * rust-exp.y (super_name): Remove "current_len". + * python/py-framefilter.c (py_print_type): Remove "type". + * mdebugread.c (parse_partial_symbols): Remove + "past_first_source_file". + : Remove "valu", "first_so_symnum", "prev_textlow_not_set". + * m2-valprint.c (m2_print_unbounded_array): Remove + "content_type". + (m2_val_print): Remove "i". + * linespec.c (unexpected_linespec_error): Remove "cleanup". + * f-valprint.c (f_val_print): Remove "i". + * elfread.c (elf_symtab_read): Remove "offset". + * dwarf2-frame.c (dwarf2_fetch_cfa_info): Remove "addr_size". + +2016-06-06 Tom Tromey + * arch-utils.c (default_skip_permanent_breakpoint): Remove "bp_insn". * disasm.c (do_assembly_only): Remove "num_displayed". diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 88fcf4b..92b57e5 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -2981,11 +2981,10 @@ aarch64_record_data_proc_reg (insn_decode_record *aarch64_insn_r) static unsigned int aarch64_record_data_proc_imm (insn_decode_record *aarch64_insn_r) { - uint8_t reg_rd, insn_bit28, insn_bit23, insn_bits24_27, setflags; + uint8_t reg_rd, insn_bit23, insn_bits24_27, setflags; uint32_t record_buf[4]; reg_rd = bits (aarch64_insn_r->aarch64_insn, 0, 4); - insn_bit28 = bit (aarch64_insn_r->aarch64_insn, 28); insn_bit23 = bit (aarch64_insn_r->aarch64_insn, 23); insn_bits24_27 = bits (aarch64_insn_r->aarch64_insn, 24, 27); diff --git a/gdb/dwarf2-frame.c b/gdb/dwarf2-frame.c index 2f6355a..11258ea 100644 --- a/gdb/dwarf2-frame.c +++ b/gdb/dwarf2-frame.c @@ -908,7 +908,6 @@ dwarf2_fetch_cfa_info (struct gdbarch *gdbarch, CORE_ADDR pc, struct dwarf2_fde *fde; CORE_ADDR text_offset; struct dwarf2_frame_state fs; - int addr_size; memset (&fs, 0, sizeof (struct dwarf2_frame_state)); @@ -923,7 +922,6 @@ dwarf2_fetch_cfa_info (struct gdbarch *gdbarch, CORE_ADDR pc, fs.data_align = fde->cie->data_alignment_factor; fs.code_align = fde->cie->code_alignment_factor; fs.retaddr_column = fde->cie->return_address_register; - addr_size = fde->cie->addr_size; /* Check for "quirks" - known bugs in producers. */ dwarf2_frame_find_quirks (&fs, fde); diff --git a/gdb/elfread.c b/gdb/elfread.c index d4400bb..e90466b 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -233,7 +233,6 @@ elf_symtab_read (struct objfile *objfile, int type, asymbol *sym; long i; CORE_ADDR symaddr; - CORE_ADDR offset; enum minimal_symbol_type ms_type; /* Name of the last file symbol. This is either a constant string or is saved on the objfile's filename cache. */ @@ -263,8 +262,6 @@ elf_symtab_read (struct objfile *objfile, int type, continue; } - offset = ANOFFSET (objfile->section_offsets, - gdb_bfd_section_index (objfile->obfd, sym->section)); if (type == ST_DYNAMIC && sym->section == bfd_und_section_ptr && (sym->flags & BSF_FUNCTION)) diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c index 1264737..f31b4c7 100644 --- a/gdb/f-valprint.c +++ b/gdb/f-valprint.c @@ -218,7 +218,6 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset, { struct gdbarch *gdbarch = get_type_arch (type); enum bfd_endian byte_order = gdbarch_byte_order (gdbarch); - unsigned int i = 0; /* Number of characters printed. */ struct type *elttype; CORE_ADDR addr; int index; @@ -292,8 +291,8 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset, { if (want_space) fputs_filtered (" ", stream); - i = val_print_string (TYPE_TARGET_TYPE (type), NULL, addr, -1, - stream, options); + val_print_string (TYPE_TARGET_TYPE (type), NULL, addr, -1, + stream, options); } return; } diff --git a/gdb/linespec.c b/gdb/linespec.c index 7162163..ccedec8 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -1519,10 +1519,9 @@ unexpected_linespec_error (linespec_parser *parser) || token.type == LSTOKEN_KEYWORD) { char *string; - struct cleanup *cleanup; string = copy_token_string (token); - cleanup = make_cleanup (xfree, string); + make_cleanup (xfree, string); throw_error (GENERIC_ERROR, _("malformed linespec error: unexpected %s, \"%s\""), token_type_strings[token.type], string); diff --git a/gdb/m2-valprint.c b/gdb/m2-valprint.c index 2d3a32f..a53aa84 100644 --- a/gdb/m2-valprint.c +++ b/gdb/m2-valprint.c @@ -162,13 +162,11 @@ m2_print_unbounded_array (struct type *type, const gdb_byte *valaddr, struct ui_file *stream, int recurse, const struct value_print_options *options) { - struct type *content_type; CORE_ADDR addr; LONGEST len; struct value *val; type = check_typedef (type); - content_type = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type, 0)); addr = unpack_pointer (TYPE_FIELD_TYPE (type, 0), (TYPE_FIELD_BITPOS (type, 0) / 8) + @@ -316,7 +314,6 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset, const struct value_print_options *options) { struct gdbarch *gdbarch = get_type_arch (type); - unsigned int i = 0; /* Number of characters printed. */ unsigned len; struct type *elttype; CORE_ADDR addr; @@ -355,7 +352,6 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset, LA_PRINT_STRING (stream, TYPE_TARGET_TYPE (type), valaddr + embedded_offset, len, NULL, 0, options); - i = len; } else { diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index c46e880..a6a2efe 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -2368,7 +2368,6 @@ parse_partial_symbols (struct objfile *objfile) SYMR sh; struct partial_symtab *pst; int textlow_not_set = 1; - int past_first_source_file = 0; /* List of current psymtab's include files. */ const char **psymtab_include_list; @@ -2957,16 +2956,8 @@ parse_partial_symbols (struct objfile *objfile) case N_SO: { - CORE_ADDR valu; static int prev_so_symnum = -10; - static int first_so_symnum; const char *p; - int prev_textlow_not_set; - - valu = sh.value + ANOFFSET (objfile->section_offsets, - SECT_OFF_TEXT (objfile)); - - prev_textlow_not_set = textlow_not_set; /* A zero value is probably an indication for the SunPRO 3.0 compiler. dbx_end_psymtab explicitly tests @@ -2974,19 +2965,12 @@ parse_partial_symbols (struct objfile *objfile) if (sh.value == 0 && gdbarch_sofun_address_maybe_missing (gdbarch)) - { - textlow_not_set = 1; - valu = 0; - } + textlow_not_set = 1; else textlow_not_set = 0; - past_first_source_file = 1; - if (prev_so_symnum != symnum - 1) { /* Here if prev stab wasn't N_SO. */ - first_so_symnum = symnum; - if (pst) { pst = (struct partial_symtab *) 0; diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index 6098f71..4e4d79e 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -2939,7 +2939,6 @@ micromips_scan_prologue (struct gdbarch *gdbarch, int non_prologue_insns = 0; long frame_offset = 0; /* Size of stack frame. */ long frame_adjust = 0; /* Offset of FP from SP. */ - CORE_ADDR frame_addr = 0; /* Value of $30, used as frame pointer. */ int prev_delay_slot = 0; int in_delay_slot; CORE_ADDR prev_pc; @@ -3068,7 +3067,6 @@ micromips_scan_prologue (struct gdbarch *gdbarch, else if (sreg == MIPS_SP_REGNUM && dreg == 30) /* (D)ADDIU $fp, $sp, imm */ { - frame_addr = sp + offset; frame_adjust = offset; frame_reg = 30; } @@ -3144,10 +3142,7 @@ micromips_scan_prologue (struct gdbarch *gdbarch, dreg = b5s5_reg (insn); if (sreg == MIPS_SP_REGNUM && dreg == 30) /* MOVE $fp, $sp */ - { - frame_addr = sp; - frame_reg = 30; - } + frame_reg = 30; else if ((sreg & 0x1c) != 0x4) /* MOVE reg, $a0-$a3 */ this_non_prologue_insn = 1; @@ -5502,8 +5497,6 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, } while (len > 0) { - /* Remember if the argument was written to the stack. */ - int stack_used_p = 0; int partial_len = (len < MIPS32_REGSIZE ? len : MIPS32_REGSIZE); if (mips_debug) @@ -5518,7 +5511,6 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, promoted to int before being stored? */ int longword_offset = 0; CORE_ADDR addr; - stack_used_p = 1; if (mips_debug) { @@ -5960,8 +5952,6 @@ mips_o64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, && len % MIPS64_REGSIZE != 0); while (len > 0) { - /* Remember if the argument was written to the stack. */ - int stack_used_p = 0; int partial_len = (len < MIPS64_REGSIZE ? len : MIPS64_REGSIZE); if (mips_debug) @@ -5976,7 +5966,6 @@ mips_o64_push_dummy_call (struct gdbarch *gdbarch, struct value *function, promoted to int before being stored? */ int longword_offset = 0; CORE_ADDR addr; - stack_used_p = 1; if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG) { if ((typecode == TYPE_CODE_INT diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c index aa25911..b663f50 100644 --- a/gdb/python/py-framefilter.c +++ b/gdb/python/py-framefilter.c @@ -211,13 +211,11 @@ py_print_type (struct ui_out *out, struct value *val) TRY { - struct type *type; struct ui_file *stb; struct cleanup *cleanup; stb = mem_fileopen (); cleanup = make_cleanup_ui_file_delete (stb); - type = check_typedef (value_type (val)); type_print (value_type (val), "", stb, -1); ui_out_field_stream (out, "type", stb); do_cleanups (cleanup); diff --git a/gdb/rust-exp.y b/gdb/rust-exp.y index c1a863c..05e59db 100644 --- a/gdb/rust-exp.y +++ b/gdb/rust-exp.y @@ -968,17 +968,15 @@ super_name (const struct rust_op *ident, unsigned int n_supers) int i; int len; VEC (int) *offsets = NULL; - unsigned int current_len, previous_len; + unsigned int current_len; struct cleanup *cleanup; cleanup = make_cleanup (VEC_cleanup (int), &offsets); current_len = cp_find_first_component (scope); - previous_len = 0; while (scope[current_len] != '\0') { VEC_safe_push (int, offsets, current_len); gdb_assert (scope[current_len] == ':'); - previous_len = current_len; /* The "::". */ current_len += 2; current_len += cp_find_first_component (scope diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 5df99ce..a7b4aae 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -840,14 +840,13 @@ rust_print_type (struct type *type, const char *varstring, case TYPE_CODE_UNION: { /* ADT enums */ - int i, len = 0; + int i; fputs_filtered ("enum ", stream); if (TYPE_TAG_NAME (type) != NULL) { fputs_filtered (TYPE_TAG_NAME (type), stream); fputs_filtered (" ", stream); - len = strlen (TYPE_TAG_NAME (type)); } fputs_filtered ("{\n", stream);