This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: patch in ada-tasks needs small fix (was: "New ARI warning Fri Feb 24 01:54:10 UTC 2012")
- From: Tristan Gingold <gingold at adacore dot com>
- To: Joel Brobecker <brobecker at adacore dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Fri, 24 Feb 2012 14:48:37 +0100
- Subject: Re: patch in ada-tasks needs small fix (was: "New ARI warning Fri Feb 24 01:54:10 UTC 2012")
- References: <20120224015410.GA23561@sourceware.org> <20120224134032.GJ2692@adacore.com>
On Feb 24, 2012, at 2:40 PM, Joel Brobecker wrote:
> Hi Tristan,
>
> On Fri, Feb 24, 2012 at 01:54:10AM +0000, GDB Administrator wrote:
>> 5a6
>>> gdb/ada-tasks.c:881: code: if assignment: An IF statement's expression contains an assignment (the GNU coding standard discourages this)
>> gdb/ada-tasks.c:881: 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))) && !TYPE_LOW_BOUND_UNDEFINED (idxtype) && !TYPE_HIGH_BOUND_UNDEFINED (idxtype))
>
> This one is for us. I confess I hadn't noticed the assignments in
> the condition, but they are indeed. I think we can rewrite the code
> relatively easily without too much change in the program structure.
Ah, I missed this rule.
> Would you take a look at that? If you don't get to it today, then
> I will try to have a look at it.
I can propose this patch, but I haven't yet tested it beyond compiling gdb:
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))
{
What kind of testing do you want ?
Tristan.