This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] sigall.exp and friends: centralize signals list.


On 07/19/2012 06:24 PM, Tom Tromey wrote:
>>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
> 
> Pedro> +for {set i 0;} {$i < [llength $signals]} {incr i;} {
> Pedro> +    # Skip the first.
> Pedro> +    if { $i == 0 } {
> Pedro> +	continue
> Pedro> +    }
> Pedro> +
> Pedro> +    set sig [lindex $signals $i]
> Pedro> +    test_one_sig $sig
> Pedro> +}
> 
> The ";"s aren't needed.  They're only needed in Tcl if you write
> multiple statements on one line, but we don't do that anyhow, or
> shouldn't, since it is bad style.

Thanks.  I copied that from elsewhere, and didn't think much about it.
I'll grep and fix the instances I find.

> 
> For the above I think it is more idiomatic in Tcl to write:
> 
> foreach sig $signals {
>     if {$sig == "ABRT"} {
>       continue
>     }
>    test_one_sig $sig
> }
> 
> That said, I don't care if you leave it as-is.

I actually started out that way.  Then I thought that:

 - There's no guarantee that we won't have duplicate signals on the
   list.  If the test some day generates two SIGABRTs, we'd still only want
   to skip only the first of those, so we'd have to change the loop.

 - We really want to skip the first signal, because that's handled
   before the loop.  It doesn't matter which signal it is.  So I concluded
   that not hard coding a signal name was a little better, and went with a for
   with index, which expresses the idea naturally.

-- 
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]