Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: gdb-patches@sourceware.org
Cc: Joel Brobecker <brobecker@adacore.com>
Subject: [commit] Fix ARI violation in ada_tasks_inferior_data_sniffer.
Date: Tue, 28 Feb 2012 17:13:00 -0000	[thread overview]
Message-ID: <1330446835-9868-1-git-send-email-brobecker@adacore.com> (raw)
In-Reply-To: <20120224163339.GK2692@adacore.com>

Hello,

I tested the patch on x86_64-linux, as well as a bareboard target with
a ravenscar profile (just for kicks).

gdb/ChangeLog:

        * ada-tasks.c (ada_tasks_inferior_data_sniffer): Rework code to
        avoid variable assignments inside condition.

Checked in.

---
 gdb/ChangeLog   |    6 ++++++
 gdb/ada-tasks.c |   16 +++++++++-------
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 6fcb90f..a4857b8 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,9 @@
+2012-02-28  Joel Brobecker  <brobecker@adacore.com>
+
+	From Tristan Gingold  <gingold@adacore.com>.
+	* ada-tasks.c (ada_tasks_inferior_data_sniffer): Rework code to
+	avoid variable assignments inside condition.
+
 2012-02-28  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
 	Fix static analysis issue found by cppcheck.
diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c
index 4c0b667..11ad262 100644
--- a/gdb/ada-tasks.c
+++ b/gdb/ada-tasks.c
@@ -870,13 +870,15 @@ ada_tasks_inferior_data_sniffer (struct ada_tasks_inferior_data *data)
 	{
 	  /* Validate.  */
 	  struct type *type = check_typedef (SYMBOL_TYPE (sym));
-	  struct type *eltype;
-	  struct type *idxtype;
-
-	  if (TYPE_CODE (type) == TYPE_CODE_ARRAY
-	      && (eltype = check_typedef (TYPE_TARGET_TYPE (type)))
-	      && TYPE_CODE (eltype) == TYPE_CODE_PTR
-	      && (idxtype = check_typedef (TYPE_INDEX_TYPE (type)))
+	  struct type *eltype = NULL;
+	  struct type *idxtype = NULL;
+
+	  if (TYPE_CODE (type) == TYPE_CODE_ARRAY)
+	    eltype = check_typedef (TYPE_TARGET_TYPE (type));
+	  if (eltype != NULL
+	      && TYPE_CODE (eltype) == TYPE_CODE_PTR)
+	    idxtype = check_typedef (TYPE_INDEX_TYPE (type));
+	  if (idxtype != NULL
 	      && !TYPE_LOW_BOUND_UNDEFINED (idxtype)
 	      && !TYPE_HIGH_BOUND_UNDEFINED (idxtype))
 	    {
-- 
1.7.1


      reply	other threads:[~2012-02-28 16:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-24  2:50 New ARI warning Fri Feb 24 01:54:10 UTC 2012 GDB Administrator
2012-02-24 13:48 ` patch in ada-tasks needs small fix (was: "New ARI warning Fri Feb 24 01:54:10 UTC 2012") Joel Brobecker
2012-02-24 13:56   ` Tristan Gingold
2012-02-24 16:49     ` Joel Brobecker
2012-02-28 17:13       ` Joel Brobecker [this message]

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=1330446835-9868-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