From: Pedro Alves <palves@redhat.com>
To: Pedro Alves <palves@redhat.com>
Cc: Tom Tromey <tromey@redhat.com>, gdb-patches@sourceware.org
Subject: cleanup some fors in the testsuite (was: Re: [PATCH] sigall.exp and friends: centralize signals list.)
Date: Thu, 19 Jul 2012 20:03:00 -0000 [thread overview]
Message-ID: <500867E2.5070509@redhat.com> (raw)
In-Reply-To: <5008645A.4010601@redhat.com>
On 07/19/2012 08:47 PM, Pedro Alves wrote:
> On 07/19/2012 08:16 PM, Tom Tromey wrote:
>>>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
>>
>> Pedro> - We really want to skip the first signal, because that's
>> Pedro> handled before the loop. It doesn't matter which signal it is.
>> Pedro> So I concluded that not hard coding a signal name was a little
>> Pedro> better, and went with a for with index, which expresses the idea
>> Pedro> naturally.
>>
>> Alternatively you can use [lrange $signals 1 end]
>
> Or even:
>
> for {set i 1} {$i < [llength $signals]} {incr i} {
>
> which in hindsight, I have no idea why I didn't do it like that, over a
> silly "if i==0 continue". :-P
>
> I'll use lrange.
I've applied this. Thanks!
2012-07-19 Pedro Alves <palves@redhat.com>
* config/monitor.exp (gdb_load): Remove redundant ';' in for loop.
* config/vx.exp (gdb_start): Likewise.
* gdb.base/printcmds.exp (test_print_repeats_10): Likewise.
* gdb.base/setvar.exp (test_set): Likewise.
* gdb.base/sigall.exp: Use foreach+lrange instead of for+continue.
* gdb.reverse/sigall-precsave.exp: Likewise.
* gdb.reverse/sigall-reverse.exp: Likewise.
---
gdb/testsuite/config/monitor.exp | 2 +-
gdb/testsuite/config/vx.exp | 2 +-
gdb/testsuite/gdb.base/printcmds.exp | 4 ++--
gdb/testsuite/gdb.base/setvar.exp | 2 +-
gdb/testsuite/gdb.base/sigall.exp | 8 +-------
gdb/testsuite/gdb.reverse/sigall-precsave.exp | 16 ++--------------
gdb/testsuite/gdb.reverse/sigall-reverse.exp | 16 ++--------------
7 files changed, 10 insertions(+), 40 deletions(-)
diff --git a/gdb/testsuite/config/monitor.exp b/gdb/testsuite/config/monitor.exp
index a40911d..361926b 100644
--- a/gdb/testsuite/config/monitor.exp
+++ b/gdb/testsuite/config/monitor.exp
@@ -159,7 +159,7 @@ proc gdb_load { arg } {
set last_gdb_file $arg;
- for { set j 1; } { $j <= 2 } {incr j; } {
+ for { set j 1 } { $j <= 2 } {incr j } {
if [target_info exists gdb,use_standard_load] {
gdb_target_exec;
if ![target_info exists gdb,no_push_conn] {
diff --git a/gdb/testsuite/config/vx.exp b/gdb/testsuite/config/vx.exp
index 335287f..29c3b1b 100644
--- a/gdb/testsuite/config/vx.exp
+++ b/gdb/testsuite/config/vx.exp
@@ -59,7 +59,7 @@ proc gdb_start { } {
global reboot
# get a connection to the board
- for { set x 0; } { $x < 3 } { incr x } {
+ for { set x 0 } { $x < 3 } { incr x } {
set shell_id [remote_open target]
if { $shell_id > 0 } {
verbose "Spawn id for remote shell is $shell_id"
diff --git a/gdb/testsuite/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp
index 993162e..4f76cec 100644
--- a/gdb/testsuite/gdb.base/printcmds.exp
+++ b/gdb/testsuite/gdb.base/printcmds.exp
@@ -424,9 +424,9 @@ proc test_print_all_chars {} {
proc test_print_repeats_10 {} {
global gdb_prompt decimal
- for { set x 1; } { $x <= 16 } { incr x; } {
+ for { set x 1 } { $x <= 16 } { incr x } {
gdb_test_no_output "set print elements $x"
- for { set e 1; } { $e <= 16 } {incr e; } {
+ for { set e 1 } { $e <= 16 } {incr e } {
set v [expr $e - 1];
set command "p &ctable2\[${v}*16\]"
if { $x < $e } {
diff --git a/gdb/testsuite/gdb.base/setvar.exp b/gdb/testsuite/gdb.base/setvar.exp
index 870d043..7faa10a 100644
--- a/gdb/testsuite/gdb.base/setvar.exp
+++ b/gdb/testsuite/gdb.base/setvar.exp
@@ -77,7 +77,7 @@ proc test_set { args } {
set count 1;
# Set up the variables.
- for {set x 0;} {$x < $length} {incr x;} {
+ for {set x 0} {$x < $length} {incr x} {
if { "[lindex $args $x]" != "" } {
set arg [lindex $args $x];
if { ($x == $final) || ([string first ".*" [lindex $args [expr $x + 1]]] >= 0) } {
diff --git a/gdb/testsuite/gdb.base/sigall.exp b/gdb/testsuite/gdb.base/sigall.exp
index 7963504..5084f22 100644
--- a/gdb/testsuite/gdb.base/sigall.exp
+++ b/gdb/testsuite/gdb.base/sigall.exp
@@ -182,13 +182,7 @@ set thissig "ABRT"
runto gen_ABRT
-for {set i 0;} {$i < [llength $signals]} {incr i;} {
- # Skip the first.
- if { $i == 0 } {
- continue
- }
-
- set sig [lindex $signals $i]
+foreach sig [lrange $signals 1 end] {
test_one_sig $sig
}
diff --git a/gdb/testsuite/gdb.reverse/sigall-precsave.exp b/gdb/testsuite/gdb.reverse/sigall-precsave.exp
index ee3240b..d0d68a6 100644
--- a/gdb/testsuite/gdb.reverse/sigall-precsave.exp
+++ b/gdb/testsuite/gdb.reverse/sigall-precsave.exp
@@ -300,13 +300,7 @@ set sig_supported 1
set thissig "ABRT"
# test signal handling
-for {set i 0;} {$i < [llength $signals]} {incr i;} {
- # Skip the first.
- if { $i == 0 } {
- continue
- }
-
- set sig [lindex $signals $i]
+foreach sig [lrange $signals 1 end] {
test_one_sig $sig
}
@@ -330,12 +324,6 @@ foreach sig [lreverse $signals] {
set sig_supported 1
set thissig "ABRT"
-for {set i 0;} {$i < [llength $signals]} {incr i;} {
- # Skip the first.
- if { $i == 0 } {
- continue
- }
-
- set sig [lindex $signals $i]
+foreach sig [lrange $signals 1 end] {
test_one_sig $sig
}
diff --git a/gdb/testsuite/gdb.reverse/sigall-reverse.exp b/gdb/testsuite/gdb.reverse/sigall-reverse.exp
index f5bbe1e..3d516ac 100644
--- a/gdb/testsuite/gdb.reverse/sigall-reverse.exp
+++ b/gdb/testsuite/gdb.reverse/sigall-reverse.exp
@@ -248,13 +248,7 @@ set sig_supported 1
set thissig "ABRT"
# test signal handling
-for {set i 0;} {$i < [llength $signals]} {incr i;} {
- # Skip the first.
- if { $i == 0 } {
- continue
- }
-
- set sig [lindex $signals $i]
+foreach sig [lrange $signals 1 end] {
test_one_sig $sig
}
@@ -280,12 +274,6 @@ foreach sig [lreverse $signals] {
set sig_supported 1
set thissig "ABRT"
-for {set i 0;} {$i < [llength $signals]} {incr i;} {
- # Skip the first.
- if { $i == 0 } {
- continue
- }
-
- set sig [lindex $signals $i]
+foreach sig [lrange $signals 1 end] {
test_one_sig $sig
}
next prev parent reply other threads:[~2012-07-19 20:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-19 14:35 [PATCH] sigall.exp and friends: centralize signals list Pedro Alves
2012-07-19 17:24 ` Tom Tromey
2012-07-19 17:33 ` Pedro Alves
2012-07-19 19:17 ` Tom Tromey
2012-07-19 19:48 ` Pedro Alves
2012-07-19 19:58 ` Tom Tromey
2012-07-19 20:03 ` Pedro Alves [this message]
2012-07-25 13:48 ` [patch] testsuite: Fix Tcl < 7.5 regression [Re: [PATCH] sigall.exp and friends: centralize signals list.] Jan Kratochvil
2012-07-25 13:51 ` Pedro Alves
2012-07-25 20:18 ` [commit] " Jan Kratochvil
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=500867E2.5070509@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=tromey@redhat.com \
/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