* New ARI warning Fri Feb 24 01:54:10 UTC 2012
@ 2012-02-24 2:50 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
0 siblings, 1 reply; 5+ messages in thread
From: GDB Administrator @ 2012-02-24 2:50 UTC (permalink / raw)
To: gdb-patches
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))
^ permalink raw reply [flat|nested] 5+ messages in thread
* patch in ada-tasks needs small fix (was: "New ARI warning Fri Feb 24 01:54:10 UTC 2012")
2012-02-24 2:50 New ARI warning Fri Feb 24 01:54:10 UTC 2012 GDB Administrator
@ 2012-02-24 13:48 ` Joel Brobecker
2012-02-24 13:56 ` Tristan Gingold
0 siblings, 1 reply; 5+ messages in thread
From: Joel Brobecker @ 2012-02-24 13:48 UTC (permalink / raw)
To: Tristan Gingold; +Cc: gdb-patches
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.
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.
Thanks,
--
Joel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: patch in ada-tasks needs small fix (was: "New ARI warning Fri Feb 24 01:54:10 UTC 2012")
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
0 siblings, 1 reply; 5+ messages in thread
From: Tristan Gingold @ 2012-02-24 13:56 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches
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.
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: patch in ada-tasks needs small fix (was: "New ARI warning Fri Feb 24 01:54:10 UTC 2012")
2012-02-24 13:56 ` Tristan Gingold
@ 2012-02-24 16:49 ` Joel Brobecker
2012-02-28 17:13 ` [commit] Fix ARI violation in ada_tasks_inferior_data_sniffer Joel Brobecker
0 siblings, 1 reply; 5+ messages in thread
From: Joel Brobecker @ 2012-02-24 16:49 UTC (permalink / raw)
To: Tristan Gingold; +Cc: gdb-patches
> > 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:
This looks good to me. I think that native testing is going to be
sufficient. If you are running out of time, no worries, I can test
and commit for you.
> 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))
Thanks!
--
Joel
^ permalink raw reply [flat|nested] 5+ messages in thread* [commit] Fix ARI violation in ada_tasks_inferior_data_sniffer.
2012-02-24 16:49 ` Joel Brobecker
@ 2012-02-28 17:13 ` Joel Brobecker
0 siblings, 0 replies; 5+ messages in thread
From: Joel Brobecker @ 2012-02-28 17:13 UTC (permalink / raw)
To: gdb-patches; +Cc: Joel Brobecker
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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-02-28 16:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [commit] Fix ARI violation in ada_tasks_inferior_data_sniffer Joel Brobecker
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox