[gdb/testsuite, tclint] Fix gdb.threads

Running tclint on the test-cases in gdb.threads shows a few problems.

Fix these.

Tested on x86_64-linux.
diff --git a/gdb/tclint.toml b/gdb/tclint.toml
index a69e2b5..47c3ce4 100644
--- a/gdb/tclint.toml
+++ b/gdb/tclint.toml
@@ -25,7 +25,6 @@
 "gdb/testsuite/gdb.cp",
 "gdb/testsuite/gdb.dwarf2",
 "gdb/testsuite/gdb.mi",
-"gdb/testsuite/gdb.threads",
 "gdb/testsuite/gdb.trace",
 # IGNORE (document reason in trailing comment):
 "gdb/testsuite/gdb.stabs", # To be removed.
diff --git a/gdb/testsuite/gdb.threads/access-mem-running-thread-exit.exp b/gdb/testsuite/gdb.threads/access-mem-running-thread-exit.exp
index 6846b38..64d2f53 100644
--- a/gdb/testsuite/gdb.threads/access-mem-running-thread-exit.exp
+++ b/gdb/testsuite/gdb.threads/access-mem-running-thread-exit.exp
@@ -54,7 +54,7 @@
       clean_restart ${::testfile}
     }
 
-    if ![runto setup_done] {
+    if {![runto setup_done]} {
 	return -1
     }
 
@@ -101,7 +101,7 @@
 	    #
 	    # Since it's reload_on_run targets that need special care,
 	    # we default to reusing the connection on most targets.
-	    if [target_info exists gdb,do_reload_on_run] {
+	    if {[target_info exists gdb,do_reload_on_run]} {
 		gdb_test "add-inferior -no-connection" "New inferior 2.*"
 	    } else {
 		gdb_test "add-inferior" "New inferior 2.*"
@@ -110,7 +110,7 @@
 
 	    gdb_load $binfile
 
-	    if ![runto setup_done] {
+	    if {![runto setup_done]} {
 		return -1
 	    }
 	}
@@ -187,7 +187,7 @@
 }
 
 foreach non_stop { "off" "on" } {
-    set stop_mode [expr ($non_stop=="off")?"all-stop":"non-stop"]
+    set stop_mode [expr {($non_stop=="off")?"all-stop":"non-stop"}]
     with_test_prefix "$stop_mode" {
 	test $non_stop
     }
diff --git a/gdb/testsuite/gdb.threads/attach-into-signal.exp b/gdb/testsuite/gdb.threads/attach-into-signal.exp
index 0629736..ca452c1 100644
--- a/gdb/testsuite/gdb.threads/attach-into-signal.exp
+++ b/gdb/testsuite/gdb.threads/attach-into-signal.exp
@@ -58,7 +58,7 @@
 		    # nonthreaded:
 		    pass $test
 		    verbose -log "$test succeeded on the attempt # $attempt of $attempts"
-		    set passes [expr $passes + 1]
+		    set passes [expr {$passes + 1}]
 		}
 		-re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*$gdb_prompt $" {
 		    set ok 0
@@ -84,11 +84,11 @@
 
 		    if { $ok == 0} {
 			# We just lack the luck, we should try it again.
-			set attempt [expr $attempt + 1]
+			set attempt [expr {$attempt + 1}]
 		    } else {
 			pass $test
 			verbose -log "$test succeeded on the attempt # $attempt of $attempts"
-			set passes [expr $passes + 1]
+			set passes [expr {$passes + 1}]
 		    }
 		}
 	    }] != 0 } {
diff --git a/gdb/testsuite/gdb.threads/attach-stopped.exp b/gdb/testsuite/gdb.threads/attach-stopped.exp
index a3926d9..0391914 100644
--- a/gdb/testsuite/gdb.threads/attach-stopped.exp
+++ b/gdb/testsuite/gdb.threads/attach-stopped.exp
@@ -40,13 +40,13 @@
     set test_spawn_id [spawn_wait_for_attach $binfile]
     set testpid [spawn_id_get_pid $test_spawn_id]
 
-    # Stop the program 
+    # Stop the program
     remote_exec build "kill -s STOP ${testpid}"
 
     clean_restart $::testfile
 
     # Verify that we can attach to the stopped process.
-       
+
     set test "$threadtype: attach2 to stopped, after setting file"
     gdb_test_multiple "attach $testpid" "$test" {
 	-re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*$gdb_prompt $" {
diff --git a/gdb/testsuite/gdb.threads/break-while-running.exp b/gdb/testsuite/gdb.threads/break-while-running.exp
index fb7994d..c1e1051 100644
--- a/gdb/testsuite/gdb.threads/break-while-running.exp
+++ b/gdb/testsuite/gdb.threads/break-while-running.exp
@@ -44,7 +44,7 @@
     gdb_test_no_output "set non-stop $non_stop"
     gdb_test_no_output "set breakpoint always-inserted $always_inserted"
 
-    if ![runto_main] {
+    if {![runto_main]} {
 	return -1
     }
 
@@ -152,8 +152,8 @@
 foreach update_thread_list { true false } {
     foreach always_inserted { "off" "on" } {
 	foreach non_stop { "off" "on" } {
-	    set stop_mode [expr ($non_stop=="off")?"all-stop":"non-stop"]
-	    set update_list_mode [expr ($update_thread_list)?"w/ithr":"wo/ithr"]
+	    set stop_mode [expr {($non_stop=="off")?"all-stop":"non-stop"}]
+	    set update_list_mode [expr {($update_thread_list)?"w/ithr":"wo/ithr"}]
 	    with_test_prefix "$update_list_mode: always-inserted $always_inserted: $stop_mode" {
 		test $update_thread_list $always_inserted $non_stop
 	    }
diff --git a/gdb/testsuite/gdb.threads/clone-attach-detach.exp b/gdb/testsuite/gdb.threads/clone-attach-detach.exp
index 3da2c3e..b0f5e52 100644
--- a/gdb/testsuite/gdb.threads/clone-attach-detach.exp
+++ b/gdb/testsuite/gdb.threads/clone-attach-detach.exp
@@ -19,7 +19,7 @@
 # clone as proxy for when libthread_db is not available.
 
 # This only works on targets with the Linux kernel.
-if ![istarget *-*-linux*] {
+if {![istarget *-*-linux*]} {
     return
 }
 
@@ -27,7 +27,7 @@
 
 standard_testfile
 
-if [prepare_for_testing "failed to prepare" $testfile $srcfile {debug}] {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug}]} {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.threads/clone-thread_db.exp b/gdb/testsuite/gdb.threads/clone-thread_db.exp
index 7ee233d..12349e2 100644
--- a/gdb/testsuite/gdb.threads/clone-thread_db.exp
+++ b/gdb/testsuite/gdb.threads/clone-thread_db.exp
@@ -16,17 +16,17 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # This only works on targets with the Linux kernel.
-if ![istarget *-*-linux*] {
+if {![istarget *-*-linux*]} {
     return
 }
 
 standard_testfile
 
-if [prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}] {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}]} {
     return -1
 }
 
-if ![runto_main] {
+if {![runto_main]} {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.threads/continue-pending-after-query.exp b/gdb/testsuite/gdb.threads/continue-pending-after-query.exp
index 5069cd2..1da2e23 100644
--- a/gdb/testsuite/gdb.threads/continue-pending-after-query.exp
+++ b/gdb/testsuite/gdb.threads/continue-pending-after-query.exp
@@ -51,7 +51,7 @@
 proc test {} {
     global srcfile gdb_prompt
 
-    if ![runto_main] {
+    if {![runto_main]} {
 	return -1
     }
 
diff --git a/gdb/testsuite/gdb.threads/continue-pending-status.exp b/gdb/testsuite/gdb.threads/continue-pending-status.exp
index 9cde85a..447b683 100644
--- a/gdb/testsuite/gdb.threads/continue-pending-status.exp
+++ b/gdb/testsuite/gdb.threads/continue-pending-status.exp
@@ -21,11 +21,11 @@
 
 standard_testfile
 
-if [prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}] {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}]} {
     return -1
 }
 
-if ![runto_main] {
+if {![runto_main]} {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.threads/create-fail.exp b/gdb/testsuite/gdb.threads/create-fail.exp
index 14f3f4b..5d633f9 100644
--- a/gdb/testsuite/gdb.threads/create-fail.exp
+++ b/gdb/testsuite/gdb.threads/create-fail.exp
@@ -33,7 +33,7 @@
 
 	clean_restart ${executable}
 
-	if ![runto_main] {
+	if {![runto_main]} {
 	    return -1
 	}
 
diff --git a/gdb/testsuite/gdb.threads/del-pending-thread-bp.exp b/gdb/testsuite/gdb.threads/del-pending-thread-bp.exp
index 1fbfc40..bdc519f 100644
--- a/gdb/testsuite/gdb.threads/del-pending-thread-bp.exp
+++ b/gdb/testsuite/gdb.threads/del-pending-thread-bp.exp
@@ -44,7 +44,7 @@
 
 gdb_locate_shlib $binfile_lib
 
-if ![runto_main] {
+if {![runto_main]} {
     return 0
 }
 
diff --git a/gdb/testsuite/gdb.threads/detach-step-over.exp b/gdb/testsuite/gdb.threads/detach-step-over.exp
index 1767464..98b412c 100644
--- a/gdb/testsuite/gdb.threads/detach-step-over.exp
+++ b/gdb/testsuite/gdb.threads/detach-step-over.exp
@@ -229,7 +229,7 @@
 
 	    set running_count 0
 	    set interrupted 0
-	    set running_expected [expr ($::n_threads + 1) * 2]
+	    set running_expected [expr {($::n_threads + 1) * 2}]
 	    gdb_test_multiple "info threads" "threads running" {
 		-re "\\(running\\)" {
 		    incr running_count
@@ -357,7 +357,7 @@
     return -1
 }
 
-if ![runto_main] {
+if {![runto_main]} {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.threads/fork-plus-threads.exp b/gdb/testsuite/gdb.threads/fork-plus-threads.exp
index 4ce88d3..c41b164 100644
--- a/gdb/testsuite/gdb.threads/fork-plus-threads.exp
+++ b/gdb/testsuite/gdb.threads/fork-plus-threads.exp
@@ -76,7 +76,7 @@
     set saw_cannot_remove_breakpoints 0
     set saw_thread_stopped 0
 
-    set expected_num_inferior_exits [expr ${detach-on-fork} == "off" ? 11 : 1]
+    set expected_num_inferior_exits [expr {${detach-on-fork} == "off" ? 11 : 1}]
 
     # Flags indicating if we have see the exit for each inferior.
     for {set i 1} {$i <= $expected_num_inferior_exits} {incr i} {
diff --git a/gdb/testsuite/gdb.threads/gcore-thread.exp b/gdb/testsuite/gdb.threads/gcore-thread.exp
index 4e00f80..f32e9b4 100644
--- a/gdb/testsuite/gdb.threads/gcore-thread.exp
+++ b/gdb/testsuite/gdb.threads/gcore-thread.exp
@@ -123,7 +123,7 @@
     }
 
     # FIXME: now what can we test about the thread state?
-    # We do not know for certain that there should be at least 
+    # We do not know for certain that there should be at least
     # three threads, because who knows what kind of many-to-one
     # mapping various OS's may do?  Let's assume that there must
     # be at least two threads:
diff --git a/gdb/testsuite/gdb.threads/hand-call-in-threads.exp b/gdb/testsuite/gdb.threads/hand-call-in-threads.exp
index fd934f5..f9c9e87 100644
--- a/gdb/testsuite/gdb.threads/hand-call-in-threads.exp
+++ b/gdb/testsuite/gdb.threads/hand-call-in-threads.exp
@@ -74,7 +74,7 @@
 # stop without returning.
 
 # Add one for the main thread.
-set total_nr_threads [expr $NR_THREADS + 1]
+set total_nr_threads [expr {$NR_THREADS + 1}]
 
 # Thread numbering in gdb is origin-1, so begin numbering at 1.
 for { set i 1 } { $i <= $total_nr_threads } { incr i } {
diff --git a/gdb/testsuite/gdb.threads/hand-call-new-thread.exp b/gdb/testsuite/gdb.threads/hand-call-new-thread.exp
index 6b859ff..479c2ff 100644
--- a/gdb/testsuite/gdb.threads/hand-call-new-thread.exp
+++ b/gdb/testsuite/gdb.threads/hand-call-new-thread.exp
@@ -18,11 +18,11 @@
 
 standard_testfile
 
-if [prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}] {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}]} {
     return -1
 }
 
-if ![runto_main] {
+if {![runto_main]} {
     return
 }
 
diff --git a/gdb/testsuite/gdb.threads/ia64-sigill.exp b/gdb/testsuite/gdb.threads/ia64-sigill.exp
index ac6ff20..46954de 100644
--- a/gdb/testsuite/gdb.threads/ia64-sigill.exp
+++ b/gdb/testsuite/gdb.threads/ia64-sigill.exp
@@ -27,7 +27,7 @@
 
 clean_restart $testfile
 
-if ![runto_main] {
+if {![runto_main]} {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.threads/inf-thr-count.exp b/gdb/testsuite/gdb.threads/inf-thr-count.exp
index 5272f5c..4508be2 100644
--- a/gdb/testsuite/gdb.threads/inf-thr-count.exp
+++ b/gdb/testsuite/gdb.threads/inf-thr-count.exp
@@ -47,7 +47,7 @@
     clean_restart $::testfile
 }
 
-if ![runto_main] {
+if {![runto_main]} {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.threads/infcall-thread-announce.exp b/gdb/testsuite/gdb.threads/infcall-thread-announce.exp
index 68fd7b7..59a5bcf 100644
--- a/gdb/testsuite/gdb.threads/infcall-thread-announce.exp
+++ b/gdb/testsuite/gdb.threads/infcall-thread-announce.exp
@@ -23,7 +23,7 @@
     return -1
 }
 
-if ![runto_main] {
+if {![runto_main]} {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.threads/info-threads-cur-sal.exp b/gdb/testsuite/gdb.threads/info-threads-cur-sal.exp
index 2d57136..784caf9 100644
--- a/gdb/testsuite/gdb.threads/info-threads-cur-sal.exp
+++ b/gdb/testsuite/gdb.threads/info-threads-cur-sal.exp
@@ -25,7 +25,7 @@
 
 clean_restart ${executable}
 
-if ![runto_main] {
+if {![runto_main]} {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.threads/info-threads-options.exp b/gdb/testsuite/gdb.threads/info-threads-options.exp
index e6c68e2..b322261 100644
--- a/gdb/testsuite/gdb.threads/info-threads-options.exp
+++ b/gdb/testsuite/gdb.threads/info-threads-options.exp
@@ -27,7 +27,7 @@
     clean_restart $::testfile
 }
 
-if ![runto_main] {
+if {![runto_main]} {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.threads/interrupt-while-step-over.exp b/gdb/testsuite/gdb.threads/interrupt-while-step-over.exp
index 44e4d64..d3f328b 100644
--- a/gdb/testsuite/gdb.threads/interrupt-while-step-over.exp
+++ b/gdb/testsuite/gdb.threads/interrupt-while-step-over.exp
@@ -84,7 +84,7 @@
 	    exp_continue
 	}
 	-re "$gdb_prompt " {
-	    if ![gdb_assert $saw_continuing $test] {
+	    if {![gdb_assert $saw_continuing $test]} {
 		return 1
 	    }
 	}
@@ -101,7 +101,7 @@
 	    exp_continue
 	}
 	-re "$gdb_prompt " {
-	    if ![gdb_assert {$running_count == $NUM_THREADS} $test] {
+	    if {![gdb_assert {$running_count == $NUM_THREADS} $test]} {
 		return 1
 	    }
 	}
@@ -151,7 +151,7 @@
 	    exp_continue
 	}
 	-re "$gdb_prompt " {
-	    if ![gdb_assert {$running_count == 0} $test] {
+	    if {![gdb_assert {$running_count == 0} $test]} {
 		return 1
 	    }
 	}
@@ -174,7 +174,7 @@
 
     gdb_test_no_output "set displaced-stepping $displaced"
 
-    if ![runto all_started] {
+    if {![runto all_started]} {
 	return
     }
     set break_line [gdb_get_line_number "set breakpoint here"]
diff --git a/gdb/testsuite/gdb.threads/kill.exp b/gdb/testsuite/gdb.threads/kill.exp
index 3e6aa8b..72f829c 100644
--- a/gdb/testsuite/gdb.threads/kill.exp
+++ b/gdb/testsuite/gdb.threads/kill.exp
@@ -23,7 +23,7 @@
 proc test {threaded} {
     global testfile srcfile decimal
 
-    with_test_prefix [expr ($threaded)?"threaded":"non-threaded"] {
+    with_test_prefix [expr {($threaded)?"threaded":"non-threaded"}] {
 
 	set options {debug}
 	if {$threaded} {
diff --git a/gdb/testsuite/gdb.threads/killed.exp b/gdb/testsuite/gdb.threads/killed.exp
index 1fa83af..635ffc8 100644
--- a/gdb/testsuite/gdb.threads/killed.exp
+++ b/gdb/testsuite/gdb.threads/killed.exp
@@ -29,7 +29,7 @@
 # There is absolutely no warranty for GDB.  Type "show warranty" for details.
 # This GDB was configured as "i686-pc-linux-gnu"...
 # (gdb) run
-# Starting program: /home/jimb/foo/play/killed 
+# Starting program: /home/jimb/foo/play/killed
 # [New Thread 1024 (LWP 6487)]
 # [New Thread 2049 (LWP 6488)]
 # [New Thread 1026 (LWP 6489)]
@@ -42,17 +42,17 @@
 # Cannot find thread 2049: generic error
 # (gdb) The program is running.  Exit anyway? (y or n) y
 # Cannot find thread 2049: generic error
-# (gdb) 
+# (gdb)
 # [7]+  Stopped                 $D6/gdb/gdb -nw killed
 # $ kill %7
-# 
+#
 # [7]+  Stopped                 $D6/gdb/gdb -nw killed
 # $ kill -9 %7
-# 
+#
 # [7]+  Stopped                 $D6/gdb/gdb -nw killed
-# $ 
+# $
 # [7]+  Killed                  $D6/gdb/gdb -nw killed
-# $ 
+# $
 
 
 standard_testfile
diff --git a/gdb/testsuite/gdb.threads/leader-exit.exp b/gdb/testsuite/gdb.threads/leader-exit.exp
index 1bc017b..85039b8 100644
--- a/gdb/testsuite/gdb.threads/leader-exit.exp
+++ b/gdb/testsuite/gdb.threads/leader-exit.exp
@@ -26,7 +26,7 @@
 
 clean_restart ${executable}
 
-if ![runto_main] {
+if {![runto_main]} {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.threads/linux-dp.exp b/gdb/testsuite/gdb.threads/linux-dp.exp
index 35cc255..c0ef9c7 100644
--- a/gdb/testsuite/gdb.threads/linux-dp.exp
+++ b/gdb/testsuite/gdb.threads/linux-dp.exp
@@ -117,7 +117,7 @@
     } else {
 	fail "create philosopher: $i"
     }
-    
+
     set threads_after {}
     gdb_test_multiple "info threads" "info threads after: $i" {
 	-re "info threads\r\n" {
@@ -172,7 +172,7 @@
     append info_threads_ptn "$i *Thread .*"
 }
 append info_threads_ptn "\[\r\n\]+$gdb_prompt $"
-set info_threads_manager_ptn "[expr $nthreads + 1] *Thread .*$info_threads_ptn"
+set info_threads_manager_ptn "[expr {$nthreads + 1}] *Thread .*$info_threads_ptn"
 
 gdb_test_multiple "info threads" "info threads 2" {
     -re "$info_threads_manager_ptn" {
@@ -241,7 +241,7 @@
 	-re ".*$gdb_prompt $" {
 	    set only_five 0
 	}
-	timeout { 
+	timeout {
 	    set only_five -1
 	}
     }
@@ -331,7 +331,7 @@
 catch {unset seen}
 array set seen {}
 for {set i 1} {$i <= $nthreads} {incr i} {
-    if [check_philosopher_stack $i seen] {
+    if {[check_philosopher_stack $i seen]} {
 	set any_interesting 1
     }
 }
diff --git a/gdb/testsuite/gdb.threads/manythreads.exp b/gdb/testsuite/gdb.threads/manythreads.exp
index 2cd296f..0a09897 100644
--- a/gdb/testsuite/gdb.threads/manythreads.exp
+++ b/gdb/testsuite/gdb.threads/manythreads.exp
@@ -22,7 +22,7 @@
 standard_testfile
 
 set opts { debug }
-if [info exists DEBUG] {
+if {[info exists DEBUG]} {
     # make check RUNTESTFLAGS='gdb.threads/manythreads.exp DEBUG=1'
     lappend opts "additional_flags=-DDEBUG"
 }
diff --git a/gdb/testsuite/gdb.threads/multi-create-ns-info-thr.exp b/gdb/testsuite/gdb.threads/multi-create-ns-info-thr.exp
index 1c3231c..c42c1a9 100644
--- a/gdb/testsuite/gdb.threads/multi-create-ns-info-thr.exp
+++ b/gdb/testsuite/gdb.threads/multi-create-ns-info-thr.exp
@@ -25,7 +25,7 @@
 gdb_test_no_output "set pagination off"
 gdb_test_no_output "set non-stop on"
 
-if ![runto_main] {
+if {![runto_main]} {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.threads/multiple-step-overs.exp b/gdb/testsuite/gdb.threads/multiple-step-overs.exp
index 84eef1a..c3456c2 100644
--- a/gdb/testsuite/gdb.threads/multiple-step-overs.exp
+++ b/gdb/testsuite/gdb.threads/multiple-step-overs.exp
@@ -35,7 +35,7 @@
     with_test_prefix "setup" {
 	clean_restart $executable
 
-	if ![runto_main] {
+	if {![runto_main]} {
 	    return -1
 	}
 
diff --git a/gdb/testsuite/gdb.threads/names.exp b/gdb/testsuite/gdb.threads/names.exp
index 6f38c4e..808fa24 100644
--- a/gdb/testsuite/gdb.threads/names.exp
+++ b/gdb/testsuite/gdb.threads/names.exp
@@ -20,11 +20,11 @@
 
 standard_testfile
 
-if [prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}] {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}]} {
     return -1
 }
 
-if ![runto "all_threads_ready"] {
+if {![runto "all_threads_ready"]} {
     return
 }
 
diff --git a/gdb/testsuite/gdb.threads/next-bp-other-thread.exp b/gdb/testsuite/gdb.threads/next-bp-other-thread.exp
index 6b696dd..293b100 100644
--- a/gdb/testsuite/gdb.threads/next-bp-other-thread.exp
+++ b/gdb/testsuite/gdb.threads/next-bp-other-thread.exp
@@ -30,7 +30,7 @@
     with_test_prefix "schedlock=$schedlock" {
 	clean_restart $::testfile
 
-	if ![runto_main] {
+	if {![runto_main]} {
 	    continue
 	}
 
diff --git a/gdb/testsuite/gdb.threads/no-unwaited-for-left.exp b/gdb/testsuite/gdb.threads/no-unwaited-for-left.exp
index edeabaf..96b5433 100644
--- a/gdb/testsuite/gdb.threads/no-unwaited-for-left.exp
+++ b/gdb/testsuite/gdb.threads/no-unwaited-for-left.exp
@@ -25,7 +25,7 @@
 
 clean_restart ${executable}
 
-if ![runto_main] {
+if {![runto_main]} {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.threads/non-ldr-exc-1.exp b/gdb/testsuite/gdb.threads/non-ldr-exc-1.exp
index 846fe89..7d2956d 100644
--- a/gdb/testsuite/gdb.threads/non-ldr-exc-1.exp
+++ b/gdb/testsuite/gdb.threads/non-ldr-exc-1.exp
@@ -31,7 +31,7 @@
       clean_restart ${executable}
     }
 
-    if ![runto_main] {
+    if {![runto_main]} {
 	return -1
     }
 
diff --git a/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp b/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp
index 860b6b5..bb66644 100644
--- a/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp
+++ b/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp
@@ -33,7 +33,7 @@
       clean_restart ${executable}
     }
 
-    if ![runto_main] {
+    if {![runto_main]} {
 	return -1
     }
 
diff --git a/gdb/testsuite/gdb.threads/non-ldr-exc-3.exp b/gdb/testsuite/gdb.threads/non-ldr-exc-3.exp
index b50bfac..4490b30 100644
--- a/gdb/testsuite/gdb.threads/non-ldr-exc-3.exp
+++ b/gdb/testsuite/gdb.threads/non-ldr-exc-3.exp
@@ -34,7 +34,7 @@
       clean_restart ${executable}
     }
 
-    if ![runto_main] {
+    if {![runto_main]} {
 	return -1
     }
 
diff --git a/gdb/testsuite/gdb.threads/non-ldr-exc-4.exp b/gdb/testsuite/gdb.threads/non-ldr-exc-4.exp
index 9892d83..533e14f 100644
--- a/gdb/testsuite/gdb.threads/non-ldr-exc-4.exp
+++ b/gdb/testsuite/gdb.threads/non-ldr-exc-4.exp
@@ -33,7 +33,7 @@
       clean_restart ${executable}
     }
 
-    if ![runto_main] {
+    if {![runto_main]} {
 	return -1
     }
 
diff --git a/gdb/testsuite/gdb.threads/non-ldr-exit.exp b/gdb/testsuite/gdb.threads/non-ldr-exit.exp
index b09a37e..4dd1b79 100644
--- a/gdb/testsuite/gdb.threads/non-ldr-exit.exp
+++ b/gdb/testsuite/gdb.threads/non-ldr-exit.exp
@@ -22,7 +22,7 @@
     return -1
 }
 
-if ![runto_main] {
+if {![runto_main]} {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.threads/non-stop-fair-events.exp b/gdb/testsuite/gdb.threads/non-stop-fair-events.exp
index 5def610..788a7e8 100644
--- a/gdb/testsuite/gdb.threads/non-stop-fair-events.exp
+++ b/gdb/testsuite/gdb.threads/non-stop-fair-events.exp
@@ -28,7 +28,7 @@
 
 gdb_test_no_output "set non-stop on"
 
-if ![runto_main] {
+if {![runto_main]} {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.threads/omp-par-scope.exp b/gdb/testsuite/gdb.threads/omp-par-scope.exp
index 27dbaf0..2a097f5 100644
--- a/gdb/testsuite/gdb.threads/omp-par-scope.exp
+++ b/gdb/testsuite/gdb.threads/omp-par-scope.exp
@@ -30,7 +30,7 @@
 
 set have_nested_function_support 0
 set opts {openmp debug}
-if [support_nested_function_tests] {
+if {[support_nested_function_tests]} {
     lappend opts "additional_flags=-DHAVE_NESTED_FUNCTION_SUPPORT"
     set have_nested_function_support 1
 }
@@ -191,7 +191,7 @@
 # Nested functions in C are a GNU extension, so only do the nested function
 # tests if compiling with -DHAVE_NESTED_FUNCTION_SUPPORT was successful.
 
-if $have_nested_function_support {
+if {$have_nested_function_support} {
     with_test_prefix "nested_func" {
 	gdb_breakpoint [gdb_get_line_number "nested_func: tn="]
 
diff --git a/gdb/testsuite/gdb.threads/print-threads.exp b/gdb/testsuite/gdb.threads/print-threads.exp
index 3d2dc14..a3fcba3 100644
--- a/gdb/testsuite/gdb.threads/print-threads.exp
+++ b/gdb/testsuite/gdb.threads/print-threads.exp
@@ -50,13 +50,13 @@
 	set j 0
 	gdb_test_multiple "continue" "all threads ran once" {
 	    -re "Breakpoint \[0-9\]+, thread_function \\(arg=.*\\) at .*print-threads.c:\[0-9\]+.*$gdb_prompt" {
-		set i [expr $i + 1]
+		set i [expr {$i + 1}]
 		pass "hit thread_function breakpoint, $i"
 		send_gdb "continue\n"
 		exp_continue
 	    }
 	    -re "Breakpoint \[0-9\]+, .* kill \\(.*\\) .*$gdb_prompt" {
-		set j [expr $j + 1]
+		set j [expr {$j + 1}]
 		if { $kill == 1 } {
 		    pass "hit kill breakpoint, $j"
 		} else {
@@ -96,7 +96,7 @@
 gdb_test "break thread_function" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*print-threads.c, line \[0-9\]*\\." "break thread_function, 2"
 gdb_test_no_output "set var slow = 1"
 # Extend the timeout for slower tests.
-set timeout [expr $oldtimeout + 120]
+set timeout [expr {$oldtimeout + 120}]
 test_all_threads "slow" 0
 set timeout $oldtimeout
 
@@ -105,6 +105,6 @@
 gdb_test_no_output "set var slow = 1" "set var slow = 1, 2"
 gdb_breakpoint "kill"
 # Extend the timeout for slower tests.
-set timeout [expr $oldtimeout + 120]
+set timeout [expr {$oldtimeout + 120}]
 test_all_threads "slow with kill breakpoint" 1
 set timeout $oldtimeout
diff --git a/gdb/testsuite/gdb.threads/process-dies-while-detaching.exp b/gdb/testsuite/gdb.threads/process-dies-while-detaching.exp
index 6c6a4b1..63ddfec 100644
--- a/gdb/testsuite/gdb.threads/process-dies-while-detaching.exp
+++ b/gdb/testsuite/gdb.threads/process-dies-while-detaching.exp
@@ -188,7 +188,7 @@
 	    perror "unhandled command: $cmd"
 	}
     } else {
-	if $is_remote {
+	if {$is_remote} {
 	    set extra "\r\nEnding remote debugging\."
 	} else {
 	    set extra ""
@@ -217,7 +217,7 @@
 
 	clean_restart ${::testfile}
 
-	if ![runto_main] {
+	if {![runto_main]} {
 	    return -1
 	}
 
@@ -245,7 +245,7 @@
 
 	clean_restart ${::testfile}
 
-	if ![runto_main] {
+	if {![runto_main]} {
 	    return -1
 	}
 
@@ -293,7 +293,7 @@
 
 	clean_restart ${::testfile}
 
-	if ![runto_main] {
+	if {![runto_main]} {
 	    return -1
 	}
 
diff --git a/gdb/testsuite/gdb.threads/pthread_cond_wait.exp b/gdb/testsuite/gdb.threads/pthread_cond_wait.exp
index e914db0..e11b904 100644
--- a/gdb/testsuite/gdb.threads/pthread_cond_wait.exp
+++ b/gdb/testsuite/gdb.threads/pthread_cond_wait.exp
@@ -17,7 +17,7 @@
 # bug-gdb@gnu.org
 
 # This file verifies that GDB is able to compute a backtrace for a thread
-# being blocked on a call to pthread_cond_wait(). 
+# being blocked on a call to pthread_cond_wait().
 
 standard_testfile
 
@@ -36,7 +36,7 @@
          ".*Breakpoint 2, break_me ().*" \
          "run to break_me"
 
-# 
+#
 # Backtrace all threads, find the one running noreturn, and
 # verify that we are able to get a sensible backtrace, including
 # the frame for the pthread_cond_wait() call.
diff --git a/gdb/testsuite/gdb.threads/queue-signal.exp b/gdb/testsuite/gdb.threads/queue-signal.exp
index 34abc3b..6ab8bbb 100644
--- a/gdb/testsuite/gdb.threads/queue-signal.exp
+++ b/gdb/testsuite/gdb.threads/queue-signal.exp
@@ -22,7 +22,7 @@
 
 clean_restart ${::testfile}
 
-if ![runto_main] {
+if {![runto_main]} {
    return 0
 }
 
diff --git a/gdb/testsuite/gdb.threads/schedlock-new-thread.exp b/gdb/testsuite/gdb.threads/schedlock-new-thread.exp
index 5fda4b8..0937e2a 100644
--- a/gdb/testsuite/gdb.threads/schedlock-new-thread.exp
+++ b/gdb/testsuite/gdb.threads/schedlock-new-thread.exp
@@ -18,7 +18,7 @@
 standard_testfile .c
 
 foreach_with_prefix schedlock {off on} {
-    set sl [expr $schedlock == "on" ? 1 : 0]
+    set sl [expr {$schedlock == "on" ? 1 : 0}]
     if { [build_executable "failed to prepare" $testfile-$sl \
 	      $srcfile \
 	      [list debug pthreads additional_flags=-DSCHEDLOCK=$sl]] \
@@ -30,7 +30,7 @@
 proc test {non-stop schedlock} {
     save_vars ::GDBFLAGS {
 	append ::GDBFLAGS " -ex \"set non-stop ${non-stop}\""
-	set sl [expr $schedlock == "on" ? 1 : 0]
+	set sl [expr {$schedlock == "on" ? 1 : 0}]
 	clean_restart $::testfile-$sl
     }
 
diff --git a/gdb/testsuite/gdb.threads/schedlock.exp b/gdb/testsuite/gdb.threads/schedlock.exp
index 4e2b835..1257868 100644
--- a/gdb/testsuite/gdb.threads/schedlock.exp
+++ b/gdb/testsuite/gdb.threads/schedlock.exp
@@ -41,7 +41,7 @@
     global NUM
 
     set pattern "(\[0-9\]+)"
-    for {set i 1} {[expr $i < $NUM]} {incr i} {
+    for {set i 1} {$i < $NUM} {incr i} {
 	append pattern ", (\[0-9\]+)"
     }
 
@@ -51,7 +51,7 @@
 	    pass $test
 
 	    set result ""
-	    for {set i 1} {[expr $i <= $NUM]} {incr i} {
+	    for {set i 1} {[expr {$i <= $NUM}]} {incr i} {
 		lappend result $expect_out($i,string)
 	    }
 	    return $result
@@ -122,7 +122,7 @@
 proc step_ten_loops { cmd } {
     global gdb_prompt
 
-    for {set i 0} {[expr $i < 10]} {set i [expr $i + 1]} {
+    for {set i 0} {$i < 10} {incr i} {
 	set other_step 0
 	set test "$cmd to increment, $i"
 	gdb_test_multiple $cmd $test {
@@ -183,7 +183,7 @@
 set cont_args [get_args "after initial"]
 
 set bad 0
-for {set i 0} {[expr $i < $NUM]} {set i [expr $i + 1]} {
+for {set i 0} {$i < $NUM} {incr i} {
   if {[lindex $start_args $i] == [lindex $cont_args $i]} {
     incr bad
   }
@@ -233,7 +233,7 @@
 	} else {
 	    if {$i == $before_thread} {
 		if {$cmd == "continue"
-		    || [lindex $before_args $i] == [expr [lindex $after_args $i] - 10]} {
+		    || [lindex $before_args $i] == [lindex $after_args $i] - 10} {
 		    pass "$test"
 		} else {
 		    fail "$test (wrong amount)"
diff --git a/gdb/testsuite/gdb.threads/siginfo-threads.exp b/gdb/testsuite/gdb.threads/siginfo-threads.exp
index ecc372d..253c4c0 100644
--- a/gdb/testsuite/gdb.threads/siginfo-threads.exp
+++ b/gdb/testsuite/gdb.threads/siginfo-threads.exp
@@ -25,7 +25,7 @@
 
 clean_restart $testfile
 
-if ![runto_main] {
+if {![runto_main]} {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.threads/signal-while-stepping-over-bp-other-thread.exp b/gdb/testsuite/gdb.threads/signal-while-stepping-over-bp-other-thread.exp
index e2f7581..b7a110d 100644
--- a/gdb/testsuite/gdb.threads/signal-while-stepping-over-bp-other-thread.exp
+++ b/gdb/testsuite/gdb.threads/signal-while-stepping-over-bp-other-thread.exp
@@ -51,7 +51,7 @@
 
 clean_restart $executable
 
-if ![runto_main] {
+if {![runto_main]} {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.threads/sigstep-threads.exp b/gdb/testsuite/gdb.threads/sigstep-threads.exp
index 0580cd0..9aed9e3 100644
--- a/gdb/testsuite/gdb.threads/sigstep-threads.exp
+++ b/gdb/testsuite/gdb.threads/sigstep-threads.exp
@@ -23,7 +23,7 @@
 
 clean_restart $executable
 
-if ![runto_main] {
+if {![runto_main]} {
     return -1
 }
 
@@ -65,7 +65,7 @@
 	    set step_at $now
 	}
     }
-    if $failed {
+    if {$failed} {
 	return
     }
 }
diff --git a/gdb/testsuite/gdb.threads/staticthreads.exp b/gdb/testsuite/gdb.threads/staticthreads.exp
index bbe11ab..44cc686 100644
--- a/gdb/testsuite/gdb.threads/staticthreads.exp
+++ b/gdb/testsuite/gdb.threads/staticthreads.exp
@@ -51,7 +51,7 @@
 	kfail gdb/1328 "$test"
     }
 }
-    
+
 
 # See if handle SIG32 helps (a little) with a static multi-threaded
 # program.
@@ -59,7 +59,7 @@
 set sig "SIG32"
 
 # SIGRTMIN is 37 on hppa-linux
-if [istarget hppa*-*-*] {
+if {[istarget hppa*-*-*]} {
   set sig "SIG37"
 }
 
@@ -98,7 +98,7 @@
 
 
 if { "$have_tls" != "" } {
-    if ![runto_main] {
+    if {![runto_main]} {
 	return -1
     }
     gdb_breakpoint [gdb_get_line_number "tlsvar-is-set"]
diff --git a/gdb/testsuite/gdb.threads/step-bg-decr-pc-switch-thread.exp b/gdb/testsuite/gdb.threads/step-bg-decr-pc-switch-thread.exp
index 309c826..82861a9 100644
--- a/gdb/testsuite/gdb.threads/step-bg-decr-pc-switch-thread.exp
+++ b/gdb/testsuite/gdb.threads/step-bg-decr-pc-switch-thread.exp
@@ -34,7 +34,7 @@
     return -1
 }
 
-if ![runto_main] {
+if {![runto_main]} {
     return
 }
 
@@ -55,7 +55,7 @@
 set test "switch to main thread"
 gdb_test_multiple "thread 1" $test {
     -re "Cannot execute this command while the target is running.*$gdb_prompt $" {
-	
+
 	# With remote targets, we can't send any other remote packet
 	# until the target stops.  Switching thread wants to ask the
 	# remote side whether the thread is alive.
diff --git a/gdb/testsuite/gdb.threads/step-over-exec.exp b/gdb/testsuite/gdb.threads/step-over-exec.exp
index b06f3a4..22b9a13 100644
--- a/gdb/testsuite/gdb.threads/step-over-exec.exp
+++ b/gdb/testsuite/gdb.threads/step-over-exec.exp
@@ -76,7 +76,7 @@
 
     gdb_test_no_output "set displaced-stepping $displaced_stepping"
 
-    if ![runto_main] {
+    if {![runto_main]} {
 	return
     }
 
diff --git a/gdb/testsuite/gdb.threads/step-over-lands-on-breakpoint.exp b/gdb/testsuite/gdb.threads/step-over-lands-on-breakpoint.exp
index 65aa2f1..3a96e0e 100644
--- a/gdb/testsuite/gdb.threads/step-over-lands-on-breakpoint.exp
+++ b/gdb/testsuite/gdb.threads/step-over-lands-on-breakpoint.exp
@@ -32,7 +32,7 @@
     with_test_prefix "displaced=$displaced: $command" {
 	clean_restart $executable
 
-	if ![runto_main] {
+	if {![runto_main]} {
 	    return
 	}
 
diff --git a/gdb/testsuite/gdb.threads/step-over-trips-on-watchpoint.exp b/gdb/testsuite/gdb.threads/step-over-trips-on-watchpoint.exp
index 9a028fe..0e99656 100644
--- a/gdb/testsuite/gdb.threads/step-over-trips-on-watchpoint.exp
+++ b/gdb/testsuite/gdb.threads/step-over-trips-on-watchpoint.exp
@@ -38,7 +38,7 @@
     global gdb_prompt
     global hex
 
-    if ${with_bp} {
+    if {${with_bp}} {
 	set prefix "with thread-specific bp"
     } else {
 	set prefix "no thread-specific bp"
@@ -49,7 +49,7 @@
 	    with_test_prefix $command {
 		clean_restart $executable
 
-		if ![runto_main] {
+		if {![runto_main]} {
 		    continue
 		}
 
@@ -106,7 +106,7 @@
 		gdb_test "p watch_me = 0" " = 0" "clear watch_me"
 		gdb_test "watch watch_me" "Hardware watchpoint .*"
 
-		if ${with_bp} {
+		if {${with_bp}} {
 		    gdb_test "b *$after_address_triggers_watch thread 1" \
 			"Breakpoint .*" \
 			"set breakpoint specific to thread 1"
diff --git a/gdb/testsuite/gdb.threads/stepi-over-clone.exp b/gdb/testsuite/gdb.threads/stepi-over-clone.exp
index d6f1680..e0b14cb 100644
--- a/gdb/testsuite/gdb.threads/stepi-over-clone.exp
+++ b/gdb/testsuite/gdb.threads/stepi-over-clone.exp
@@ -58,8 +58,8 @@
 # Return true if INSN is a syscall instruction.
 
 proc is_syscall_insn { insn } {
-    if [istarget x86_64-*-* ] {
-	return { $insn == "syscall" }
+    if {[istarget x86_64-*-* ]} {
+	return [string equal $insn "syscall"]
     } else {
 	error "port me"
     }
@@ -76,7 +76,7 @@
     -re "^(?:=>)?\\s+(${hex})\\s+<\\+${decimal}>:\\s+(\[^\r\n\]+)\r\n" {
 	set addr $expect_out(1,string)
 	set insn [string trim $expect_out(2,string)]
-	if [is_syscall_insn $insn] {
+	if {[is_syscall_insn $insn]} {
 	    verbose -log "Found a syscall at: $addr"
 	    lappend syscall_addrs $addr
 	}
diff --git a/gdb/testsuite/gdb.threads/stepi-random-signal.exp b/gdb/testsuite/gdb.threads/stepi-random-signal.exp
index 8ac81e8..a2d7743 100644
--- a/gdb/testsuite/gdb.threads/stepi-random-signal.exp
+++ b/gdb/testsuite/gdb.threads/stepi-random-signal.exp
@@ -31,7 +31,7 @@
 clean_restart $executable
 
 # Start the second thread.
-if ![runto start] {
+if {![runto start]} {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.threads/thread-bp-deleted.exp b/gdb/testsuite/gdb.threads/thread-bp-deleted.exp
index 8001229..19b5001 100644
--- a/gdb/testsuite/gdb.threads/thread-bp-deleted.exp
+++ b/gdb/testsuite/gdb.threads/thread-bp-deleted.exp
@@ -31,9 +31,10 @@
 
 # We need to do things a little differently when using the remote protocol.
 set is_remote \
-    [expr [target_info exists gdb_protocol] \
-	 && ([string equal [target_info gdb_protocol] "remote"] \
-	     || [string equal [target_info gdb_protocol] "extended-remote"])]
+    [expr \
+	 {[target_info exists gdb_protocol]
+	     && ([string equal [target_info gdb_protocol] "remote"]
+		 || [string equal [target_info gdb_protocol] "extended-remote"])}]
 
 # This test requires background execution, which relies on non-stop mode.
 save_vars { GDBFLAGS } {
diff --git a/gdb/testsuite/gdb.threads/thread-execl.exp b/gdb/testsuite/gdb.threads/thread-execl.exp
index 13a6ef4..d1c80df 100644
--- a/gdb/testsuite/gdb.threads/thread-execl.exp
+++ b/gdb/testsuite/gdb.threads/thread-execl.exp
@@ -41,7 +41,7 @@
 	    gdb_test_no_output "set non-stop 1"
 	}
 
-	if ![runto_main] {
+	if {![runto_main]} {
 	    return 0
 	}
 
diff --git a/gdb/testsuite/gdb.threads/thread_check.exp b/gdb/testsuite/gdb.threads/thread_check.exp
index 9f92066..6378e8a 100644
--- a/gdb/testsuite/gdb.threads/thread_check.exp
+++ b/gdb/testsuite/gdb.threads/thread_check.exp
@@ -15,16 +15,16 @@
 
 # This file was written by Manoj Iyer. (manjo@austin.ibm.com)
 # Test break points and single step on thread functions.
-# 
+#
 # Test Purpose:
-# - Test that breakpoints, continue in a threaded  application works. 
+# - Test that breakpoints, continue in a threaded  application works.
 #   On powerpc64-unknown-linux-gnu system, running kernel version
 #   2.6.5-7.71-pseries64 this test is known to fail due to kernel bug
 #   in ptrace system call.
 #
 # Test Strategy:
 # - thread_check.c creates 2 threads
-# - start gdb 
+# - start gdb
 # - create 2 breakpoints #1 main() #2 tf() (the thread function)
 # - run gdb till #1 main() breakpoint is reached
 # - continue to breakpoint #2 tf()
@@ -62,7 +62,7 @@
      ".*Breakpoint 2,.*tf.*at.*$srcfile:.*" \
      "continue to tf"
 
-#   
+#
 # backtrace from thread function.
 #
 gdb_test "backtrace" \
diff --git a/gdb/testsuite/gdb.threads/threadapply.exp b/gdb/testsuite/gdb.threads/threadapply.exp
index 34de561..de264b6 100644
--- a/gdb/testsuite/gdb.threads/threadapply.exp
+++ b/gdb/testsuite/gdb.threads/threadapply.exp
@@ -60,7 +60,7 @@
 # Go into the thread_function to check that a simple "thread apply"
 # does not change the selected frame.
 gdb_test "step" "thread_function.*" "step to the thread_function"
-gdb_test "up" ".*in main.*" "go up in the stack frame" 
+gdb_test "up" ".*in main.*" "go up in the stack frame"
 gdb_test "thread apply all print 1"  "Thread ..*\\\$\[0-9]+ = 1.*Thread ..*\\\$\[0-9]+ = 1.*Thread ..*\\\$\[0-9]+ = 1.*Thread ..*\\\$\[0-9]+ = 1.*Thread ..*\\\$\[0-9]+ = 1.*Thread ..*\\\$\[0-9]+ = 1" "run a simple print command on all threads"
 gdb_test "down" "#0.*thread_function.*" "go down and check selected frame"
 
@@ -75,7 +75,7 @@
 
 	clean_restart ${::testfile}
 
-	if ![runto_main] {
+	if {![runto_main]} {
 	    return -1
 	}
 
@@ -104,7 +104,7 @@
 
     # The test starts multiple inferiors, therefore non-extended
     # remote is not supported.
-    if [use_gdb_stub] {
+    if {[use_gdb_stub]} {
 	unsupported "using gdb stub"
 	return
     }
diff --git a/gdb/testsuite/gdb.threads/threadcrash.exp b/gdb/testsuite/gdb.threads/threadcrash.exp
index 8df8578..d57f437 100644
--- a/gdb/testsuite/gdb.threads/threadcrash.exp
+++ b/gdb/testsuite/gdb.threads/threadcrash.exp
@@ -134,7 +134,7 @@
 
     set loop_iterations [llength $test_list]
     for {set i 0} {$i < $loop_iterations } {incr i} {
-	set thread_num [expr $loop_iterations - $i]
+	set thread_num [expr {$loop_iterations - $i}]
 
 	set type [lindex $test_list $i]
 	if { $type == 1 } {
@@ -271,8 +271,8 @@
 
 standard_testfile
 
-if [prepare_for_testing "failed to prepare" $testfile $srcfile \
-    {debug pthreads}] {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile \
+	 {debug pthreads}]} {
     return -1
 }
 
diff --git a/gdb/testsuite/gdb.threads/threads-after-exec.exp b/gdb/testsuite/gdb.threads/threads-after-exec.exp
index db26315..a6a3fb7 100644
--- a/gdb/testsuite/gdb.threads/threads-after-exec.exp
+++ b/gdb/testsuite/gdb.threads/threads-after-exec.exp
@@ -19,11 +19,11 @@
 standard_testfile .c
 
 proc do_test { } {
-    if [prepare_for_testing "failed to prepare" $::testfile $::srcfile {debug pthreads}] {
+    if {[prepare_for_testing "failed to prepare" $::testfile $::srcfile {debug pthreads}]} {
 	return -1
     }
 
-    if ![runto_main] {
+    if {![runto_main]} {
 	return
     }
 
diff --git a/gdb/testsuite/gdb.threads/tid-reuse.exp b/gdb/testsuite/gdb.threads/tid-reuse.exp
index 6762127..ca5edc1 100644
--- a/gdb/testsuite/gdb.threads/tid-reuse.exp
+++ b/gdb/testsuite/gdb.threads/tid-reuse.exp
@@ -22,7 +22,7 @@
     return -1
 }
 
-if ![runto_main] {
+if {![runto_main]} {
     return -1
 }
 
@@ -72,6 +72,6 @@
 gdb_breakpoint "after_reuse_time"
 
 # Higher than what the test program sleeps before exiting.
-set timeout [expr $reuse_time * 2]
+set timeout [expr {$reuse_time * 2}]
 
 gdb_continue_to_breakpoint "after_reuse_time"
diff --git a/gdb/testsuite/gdb.threads/tls-sepdebug.exp b/gdb/testsuite/gdb.threads/tls-sepdebug.exp
index 6f3c711..fb684c9 100644
--- a/gdb/testsuite/gdb.threads/tls-sepdebug.exp
+++ b/gdb/testsuite/gdb.threads/tls-sepdebug.exp
@@ -83,7 +83,7 @@
 
 	gdb_load ${binmainfile}
 
-	if ![runto_main] {
+	if {![runto_main]} {
 	    return
 	}
 
diff --git a/gdb/testsuite/gdb.threads/tls-shared.exp b/gdb/testsuite/gdb.threads/tls-shared.exp
index b7fa965..66dd52f 100644
--- a/gdb/testsuite/gdb.threads/tls-shared.exp
+++ b/gdb/testsuite/gdb.threads/tls-shared.exp
@@ -52,6 +52,6 @@
 gdb_test "continue" \
 	"main .* at .*:.*return 0.*break here to check result.*" \
         "continue to break"
-# This is more of a gcc/glibc test, really. 
+# This is more of a gcc/glibc test, really.
 #
 gdb_test "print result" "3"
diff --git a/gdb/testsuite/gdb.threads/tls-var.exp b/gdb/testsuite/gdb.threads/tls-var.exp
index de74bd9..8d8b82e 100644
--- a/gdb/testsuite/gdb.threads/tls-var.exp
+++ b/gdb/testsuite/gdb.threads/tls-var.exp
@@ -27,7 +27,7 @@
 
 clean_restart ${executable}
 
-if ![runto_main] {
+if {![runto_main]} {
     return 0
 }
 
diff --git a/gdb/testsuite/gdb.threads/tls.exp b/gdb/testsuite/gdb.threads/tls.exp
index 4b43387..3dbc802 100644
--- a/gdb/testsuite/gdb.threads/tls.exp
+++ b/gdb/testsuite/gdb.threads/tls.exp
@@ -56,7 +56,7 @@
 	    fail "$tnum thread print me"
 	}
 	timeout {
-	    fail "$tnum thread print me (timeout)" 
+	    fail "$tnum thread print me (timeout)"
 	}
     }
     return ${value_of_me}
@@ -116,8 +116,8 @@
 
 ### Do a backtrace for the current thread, and check that the 'spin' routine
 ### is in it. This means we have one of the threads we created, rather
-### than the main thread. Record the thread in the spin_threads 
-### array. Also remember the level of the 'spin' routine in the backtrace, for 
+### than the main thread. Record the thread in the spin_threads
+### array. Also remember the level of the 'spin' routine in the backtrace, for
 ### later use.
 proc check_thread_stack {number spin_threads spin_threads_level} {
     global gdb_prompt
@@ -148,7 +148,7 @@
 	 pass "backtrace of thread number $number not relevant"
 	}
 	timeout {
-	    fail "backtrace of thread number $number (timeout)" 
+	    fail "backtrace of thread number $number (timeout)"
 	}
     }
 }
@@ -169,7 +169,7 @@
 }
 
 # Set a breakpoint at the "spin" routine to
-# test the thread local's value.  
+# test the thread local's value.
 #
 gdb_test "b [gdb_get_line_number "here we know tls value"]" \
          ".*Breakpoint 2.*tls.*"   "set breakpoint at all threads"
@@ -247,7 +247,7 @@
 unset spin_threads_level
 
 # For each thread check its backtrace to see if it is stopped at the
-# spin routine. 
+# spin routine.
 for {set i 1} {$i <= $no_of_threads} {incr i} {
     check_thread_stack $i spin_threads spin_threads_level
 }
@@ -268,7 +268,7 @@
       # any intermediate point in spin, too, but that is much less
       # likely.
       gdb_test "up $level" ".*spin.*sem_(wait|post).*" "thread $i up"
-      check_thread_local $i 
+      check_thread_local $i
     }
 }
 
@@ -278,7 +278,7 @@
 
 gdb_test "continue" ".*Breakpoint 4.*before exit.*" "threads exited"
 
-send_gdb "info thread\n" 
+send_gdb "info thread\n"
 gdb_expect {
     -re ".* 1 *${tdlabel_re}.*2 *${tdlabel_re}.*$gdb_prompt $" {
         fail "too many threads left at end"
diff --git a/gdb/testsuite/gdb.threads/watchpoint-fork.exp b/gdb/testsuite/gdb.threads/watchpoint-fork.exp
index 8e9b1c3..68fc99e 100644
--- a/gdb/testsuite/gdb.threads/watchpoint-fork.exp
+++ b/gdb/testsuite/gdb.threads/watchpoint-fork.exp
@@ -69,7 +69,7 @@
 	    # Testcase uses it for the `follow-fork-mode child' type.
 	    gdb_test "handle SIGUSR1 nostop noprint pass" "No\[ \t\]+No\[ \t\]+Yes.*"
 
-	    if ![runto_main] {
+	    if {![runto_main]} {
 		return
 	    }
 
@@ -126,7 +126,7 @@
 	    # Testcase uses it for the `follow-fork-mode child' type.
 	    gdb_test "handle SIGUSR1 nostop noprint pass" "No\[ \t\]+No\[ \t\]+Yes.*"
 
-	    if ![runto_main] {
+	    if {![runto_main]} {
 		return
 	    }
 
@@ -165,7 +165,7 @@
 test parent FOLLOW_PARENT
 
 # Only GNU/Linux is known to support `set follow-fork-mode child'.
-if [istarget "*-*-linux*"] {
+if {[istarget "*-*-linux*"]} {
     test child FOLLOW_CHILD
 } else {
     untested "${testfile}: child"
diff --git a/gdb/testsuite/gdb.threads/watchthreads-reorder.exp b/gdb/testsuite/gdb.threads/watchthreads-reorder.exp
index 5d98913..067986a 100644
--- a/gdb/testsuite/gdb.threads/watchthreads-reorder.exp
+++ b/gdb/testsuite/gdb.threads/watchthreads-reorder.exp
@@ -41,7 +41,7 @@
 
     gdb_test "set can-use-hw-watchpoints 1"
 
-    if ![runto_main] {
+    if {![runto_main]} {
 	return -1
     }
 
@@ -72,7 +72,7 @@
 	     "Hardware read watchpoint \[0-9\]+: thread\[12\]_rwatch\r\n\r\nValue = 0\r\n0x\[0-9a-f\]+ in thread\[12\]_func .*" \
 	     "continue a"
 
-    if $reorder {
+    if {$reorder} {
 	# GDB orders watchpoints by their addresses so inserting new variables
 	# with lower addresses will shift the former watchpoints to higher
 	# debug registers.
diff --git a/gdb/testsuite/gdb.threads/watchthreads.exp b/gdb/testsuite/gdb.threads/watchthreads.exp
index f3ec7f4..e2d629d 100644
--- a/gdb/testsuite/gdb.threads/watchthreads.exp
+++ b/gdb/testsuite/gdb.threads/watchthreads.exp
@@ -67,11 +67,11 @@
 	# At least one hardware watchpoint was hit.  Check if both were.
 	set string $expect_out(1,string)
 
-	if [regexp "Hardware watchpoint 2: args\\\[0\\\]\[^\r\]*\r\[^\r\]*\r\[^\r\]*Old value = $args_0\[^\r\]*\r\[^\r\]*New value = [expr $args_0+1]\r" $string] {
+	if {[regexp "Hardware watchpoint 2: args\\\[0\\\]\[^\r\]*\r\[^\r\]*\r\[^\r\]*Old value = $args_0\[^\r\]*\r\[^\r\]*New value = [expr {$args_0+1}]\r" $string]} {
 	    incr args_0
 	    incr test_flag_0
 	}
-	if [regexp "Hardware watchpoint 3: args\\\[1\\\]\[^\r\]*\r\[^\r\]*\r\[^\r\]*Old value = $args_1\[^\r\]*\r\[^\r\]*New value = [expr $args_1+1]\r" $string] {
+	if {[regexp "Hardware watchpoint 3: args\\\[1\\\]\[^\r\]*\r\[^\r\]*\r\[^\r\]*Old value = $args_1\[^\r\]*\r\[^\r\]*New value = [expr {$args_1+1}]\r" $string]} {
 	    incr args_1
 	    incr test_flag_1
 	}
@@ -97,7 +97,7 @@
 	    }
 	}
 
-	if [ regexp "$expected_loc" $string ] {
+	if {[ regexp "$expected_loc" $string ]} {
 	    set test_flag 1
 	} else {
 	    fail "threaded watch loop"
@@ -140,23 +140,23 @@
 # Verify that we hit first watchpoint in main thread.
 set message "first watchpoint on args\[0\] hit"
 if { $args_0 > 0 } {
-  pass $message 
+  pass $message
 } else {
-  fail $message 
+  fail $message
 }
 
 # Verify that we hit second watchpoint in main thread.
 set message "first watchpoint on args\[1\] hit"
 if { $args_1 > 0 } {
-  pass $message 
+  pass $message
 } else {
-  fail $message 
+  fail $message
 }
 
 # Verify that we hit first watchpoint in child thread.
 set message "watchpoint on args\[0\] hit in thread"
 if { $args_0 > 1 } {
-  pass $message 
+  pass $message
 } else {
   fail $message
 }
@@ -164,9 +164,9 @@
 # Verify that we hit second watchpoint in child thread.
 set message "watchpoint on args\[1\] hit in thread"
 if { $args_1 > 1 } {
-  pass $message 
+  pass $message
 } else {
-  fail $message 
+  fail $message
 }
 
 # Verify that all watchpoint hits are accounted for.
@@ -174,12 +174,12 @@
 if { [target_no_stopped_data] } {
     # See above.  If we allow two watchpoints to be hit at once, we
     # may have more than 30 hits total.
-    set result [expr $args_0 + $args_1 >= 30]
+    set result [expr {$args_0 + $args_1 >= 30}]
 } else {
-    set result [expr $args_0 + $args_1 == 30]
+    set result [expr {$args_0 + $args_1 == 30}]
 }
 if { $result } {
-  pass $message 
+  pass $message
 } else {
-  fail $message 
+  fail $message
 }
diff --git a/gdb/testsuite/gdb.threads/watchthreads2.exp b/gdb/testsuite/gdb.threads/watchthreads2.exp
index 19a60e4..a31c1a7 100644
--- a/gdb/testsuite/gdb.threads/watchthreads2.exp
+++ b/gdb/testsuite/gdb.threads/watchthreads2.exp
@@ -89,7 +89,7 @@
 
 # X is incremented under a mutex, so we should get NR_THREADS * X_INCR_COUNT
 # hits.
-set limit [expr $NR_THREADS*$X_INCR_COUNT]
+set limit [expr {$NR_THREADS*$X_INCR_COUNT}]
 set x_count 0
 set done 0
 
@@ -102,7 +102,7 @@
 	-re "(.*Hardware watchpoint.*)$gdb_prompt $" {
 	    set string $expect_out(1,string)
 
-	    if [regexp "Hardware watchpoint 3: x\[^\r\]*\r\[^\r\]*\r\[^\r\]*Old value = $x_count\[^\r\]*\r\[^\r\]*New value = [expr $x_count+1]\r" $string] {
+	    if {[regexp "Hardware watchpoint 3: x\[^\r\]*\r\[^\r\]*\r\[^\r\]*Old value = $x_count\[^\r\]*\r\[^\r\]*New value = [expr {$x_count+1}]\r" $string]} {
 		incr x_count
 		set test_flag 1
 	    } else {
diff --git a/gdb/testsuite/gdb.threads/wp-replication.exp b/gdb/testsuite/gdb.threads/wp-replication.exp
index 8a5f95d..1b63d57 100644
--- a/gdb/testsuite/gdb.threads/wp-replication.exp
+++ b/gdb/testsuite/gdb.threads/wp-replication.exp
@@ -126,7 +126,7 @@
       "set var test_ready=1"
 
 # Set the number of expected watchpoint triggers.
-set TRIGGERS [expr "$NR_THREADS * $hwatch_count * $NR_TRIGGERS_PER_THREAD"]
+set TRIGGERS [expr {$NR_THREADS * $hwatch_count * $NR_TRIGGERS_PER_THREAD}]
 
 # Move the threads and hit the watchpoints TRIGGERS times.
 for { set i 1 } { $i <= $TRIGGERS } { incr i } {