From: Joel Brobecker <brobecker@adacore.com>
To: gdb-patches@sourceware.org
Cc: Joel Brobecker <brobecker@adacore.com>
Subject: [commit/Ada] move some variables to scope where they are used
Date: Wed, 03 Nov 2010 23:23:00 -0000 [thread overview]
Message-ID: <1288826583-17972-1-git-send-email-brobecker@adacore.com> (raw)
I noticed that some variables are only used inside one side of
an if/else blob. So I moved these variables inside that block for
better clarity.
gdb/ChangeLog:
* ada-valprint.c (ada_val_print_array): Move variables `eltlen'
and `len' declaration and computation inside block where they
are being used.
Tested on x86_64-linux. Checked in.
---
gdb/ChangeLog | 6 ++++++
gdb/ada-valprint.c | 23 ++++++++++++-----------
2 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 221868b..baedb0b 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,11 @@
2010-11-03 Joel Brobecker <brobecker@adacore.com>
+ * ada-valprint.c (ada_val_print_array): Move variables `eltlen'
+ and `len' declaration and computation inside block where they
+ are being used.
+
+2010-11-03 Joel Brobecker <brobecker@adacore.com>
+
* valprint.c (val_print_array_elements): Put back handling of
empty arrays.
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index 2ab2ba2..ae2a47d 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -603,23 +603,24 @@ ada_val_print_array (struct type *type, const gdb_byte *valaddr,
{
enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
struct type *elttype = TYPE_TARGET_TYPE (type);
- unsigned int eltlen;
- unsigned int len;
int result = 0;
- if (elttype == NULL)
- eltlen = 0;
- else
- eltlen = TYPE_LENGTH (elttype);
- if (eltlen == 0)
- len = 0;
- else
- len = TYPE_LENGTH (type) / eltlen;
-
/* For an array of chars, print with string syntax. */
if (ada_is_string_type (type)
&& (options->format == 0 || options->format == 's'))
{
+ unsigned int eltlen;
+ unsigned int len;
+
+ if (elttype == NULL)
+ eltlen = 0;
+ else
+ eltlen = TYPE_LENGTH (elttype);
+ if (eltlen == 0)
+ len = 0;
+ else
+ len = TYPE_LENGTH (type) / eltlen;
+
if (options->prettyprint_arrays)
print_spaces_filtered (2 + 2 * recurse, stream);
--
1.7.1
reply other threads:[~2010-11-03 23:23 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1288826583-17972-1-git-send-email-brobecker@adacore.com \
--to=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).