From patchwork Sun Dec 8 18:29:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 36591 Received: (qmail 101390 invoked by alias); 8 Dec 2019 18:30:24 -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 101168 invoked by uid 89); 8 Dec 2019 18:30:16 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=type_byte_order, H*r:esmtpa, H*RU:esmtpa, HX-Spam-Relays-External:esmtpa X-HELO: gateway30.websitewelcome.com Received: from gateway30.websitewelcome.com (HELO gateway30.websitewelcome.com) (192.185.151.58) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 08 Dec 2019 18:30:13 +0000 Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway30.websitewelcome.com (Postfix) with ESMTP id DE3B84108 for ; Sun, 8 Dec 2019 12:30:03 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id e1JjipQmCqNtve1JjiYrPL; Sun, 08 Dec 2019 12:30:03 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=xo05vBazB7nGoOsprM/CBZKecMtmY/YQbECKwqn/82g=; b=BXQpg3I2JvIOYE/X2tiiUPnbet MMosNYgbeBmCyenFcfI13LnHikmWHaNDLXGnAAR55nPtFCejpkxH+tjUUkwS9+bh+t5emJDnUlhII +81m1L9F+kZY4hUSTQY5xsxjH; Received: from 75-166-123-50.hlrn.qwest.net ([75.166.123.50]:53620 helo=bapiya.Home) by box5379.bluehost.com with esmtpa (Exim 4.92) (envelope-from ) id 1ie1Jj-0045Dk-Nd; Sun, 08 Dec 2019 11:30:03 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 15/55] Simplify c_val_print_array Date: Sun, 8 Dec 2019 11:29:18 -0700 Message-Id: <20191208182958.10181-16-tom@tromey.com> In-Reply-To: <20191208182958.10181-1-tom@tromey.com> References: <20191208182958.10181-1-tom@tromey.com> This slightly simplifies c_val_print_array by moving a variable to a more inner scope and removing a dead assignment. gdb/ChangeLog 2019-12-08 Tom Tromey * c-valprint.c (c_val_print_array): Simplify. Change-Id: I75bbd574b5619d71045f504112b53ac0f4f1aaf7 --- gdb/ChangeLog | 4 ++++ gdb/c-valprint.c | 7 +------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c index d20a411252f..5753a5869c3 100644 --- a/gdb/c-valprint.c +++ b/gdb/c-valprint.c @@ -247,7 +247,6 @@ c_val_print_array (struct type *type, const gdb_byte *valaddr, LONGEST low_bound, high_bound; int eltlen, len; enum bfd_endian byte_order = type_byte_order (type); - unsigned int i = 0; /* Number of characters printed. */ if (!get_array_bounds (type, &low_bound, &high_bound)) error (_("Could not determine the array high bound")); @@ -307,10 +306,10 @@ c_val_print_array (struct type *type, const gdb_byte *valaddr, LA_PRINT_STRING (stream, unresolved_elttype, valaddr + embedded_offset * unit_size, len, NULL, force_ellipses, options); - i = len; } else { + unsigned int i = 0; fprintf_filtered (stream, "{"); /* If this is a virtual function table, print the 0th entry specially, and the rest of the members @@ -321,10 +320,6 @@ c_val_print_array (struct type *type, const gdb_byte *valaddr, fprintf_filtered (stream, _("%d vtable entries"), len - 1); } - else - { - i = 0; - } val_print_array_elements (type, embedded_offset, address, stream, recurse, original_value, options, i);