From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21127 invoked by alias); 28 Feb 2012 16:34:19 -0000 Received: (qmail 20960 invoked by uid 22791); 28 Feb 2012 16:34:17 -0000 X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,BAYES_00,KAM_STOCKGEN,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 28 Feb 2012 16:34:04 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 2CDAD1C6A7D; Tue, 28 Feb 2012 11:34:03 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 0qttFQrjzK03; Tue, 28 Feb 2012 11:34:03 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id E88ED1C6A78; Tue, 28 Feb 2012 11:34:02 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id E2549145615; Tue, 28 Feb 2012 08:33:57 -0800 (PST) From: Joel Brobecker To: gdb-patches@sourceware.org Cc: Joel Brobecker Subject: [commit] Fix ARI violation in ada_tasks_inferior_data_sniffer. Date: Tue, 28 Feb 2012 17:13:00 -0000 Message-Id: <1330446835-9868-1-git-send-email-brobecker@adacore.com> In-Reply-To: <20120224163339.GK2692@adacore.com> References: <20120224163339.GK2692@adacore.com> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-02/txt/msg00663.txt.bz2 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 + + From Tristan Gingold . + * ada-tasks.c (ada_tasks_inferior_data_sniffer): Rework code to + avoid variable assignments inside condition. + 2012-02-28 Jan Kratochvil 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