[14/14] gdb/testsuite: remove use of then keyword from library files

Message ID c9dc4ea320fad3f4741ce816c1223858a67809db.1668508387.git.aburgess@redhat.com
State Committed
Commit d4c4542312ca16fe83c8dc8d8acce4667aa7992c
Headers
Series Remove all uses of 'then' keyword from the testsuite |

Commit Message

Andrew Burgess Nov. 15, 2022, 10:42 a.m. UTC
  The canonical form of 'if' in modern TCL is 'if {} {}'.  But there's
still a bunch of places in the testsuite where we make use of the
'then' keyword, and sometimes these get copies into new tests, which
just spreads poor practice.

This commit removes all use of the 'then' keyword from the testsuite
library files (in boards/, config/, and lib/).  Previous commits have
removed all uses of the 'then' keyword from the test script files,
this commit just cleans up the library files.

There should be no changes in what is tested after this commit.
---
 .../boards/native-extended-gdbserver.exp      |  4 +-
 gdb/testsuite/config/sid.exp                  | 16 ++---
 gdb/testsuite/config/sim.exp                  | 10 +--
 gdb/testsuite/config/slite.exp                |  8 +--
 gdb/testsuite/lib/cp-support.exp              | 64 +++++++++----------
 gdb/testsuite/lib/dwarf.exp                   | 10 +--
 gdb/testsuite/lib/gdb.exp                     | 62 +++++++++---------
 gdb/testsuite/lib/mi-support.exp              | 24 +++----
 gdb/testsuite/lib/prompt.exp                  |  2 +-
 gdb/testsuite/lib/selftest-support.exp        | 12 ++--
 gdb/testsuite/lib/trace-support.exp           |  6 +-
 11 files changed, 109 insertions(+), 109 deletions(-)
  

Patch

diff --git a/gdb/testsuite/boards/native-extended-gdbserver.exp b/gdb/testsuite/boards/native-extended-gdbserver.exp
index 67acc6fea7c..88857d6a905 100644
--- a/gdb/testsuite/boards/native-extended-gdbserver.exp
+++ b/gdb/testsuite/boards/native-extended-gdbserver.exp
@@ -113,7 +113,7 @@  proc gdb_reload { {inferior_args {}} } {
 # to a separate non-dbx testcase, we should be able to remove this.
 proc gdb_load { arg } {
     if { $arg != "" } {
-	if [gdb_file_cmd $arg] then { return -1 }
+	if {[gdb_file_cmd $arg]} { return -1 }
     }
 
     return [extended_gdbserver_load_last_file]
@@ -129,7 +129,7 @@  proc mi_gdb_load { arg } {
     global mi_gdb_prompt
 
     set res [extended_gdbserver_mi_gdb_load $arg]
-    if { $res } then { return -1 }
+    if {$res} { return -1 }
 
     send_gdb "100-gdb-set remote exec-file $arg\n"
     gdb_expect 10 {
diff --git a/gdb/testsuite/config/sid.exp b/gdb/testsuite/config/sid.exp
index e78317725a6..592663082c0 100644
--- a/gdb/testsuite/config/sid.exp
+++ b/gdb/testsuite/config/sid.exp
@@ -22,7 +22,7 @@  proc sid_start {} {
 	{ *big-endian* *-EB* *-meb* } { set sidendian "-EB" }
 	{ *little-endian* *-EL* *-mel* } { set sidendian "-EL" }
 	default { 
-	    if {[target_info exists sim,defaultendian]} then {
+	    if {[target_info exists sim,defaultendian]} {
 		set sidendian [target_info sim,defaultendian] 
 	    } else { 
                 # rely on endianness settings in sid configuration defaults
@@ -39,12 +39,12 @@  proc sid_start {} {
     # test to see whether to use use sid in build or install tree
     set use_build_tree [file exists ../../sid]
 
-    if {$use_build_tree} then {
+    if {$use_build_tree} {
 	set pre_spawn {
 	    global env
 	    set env(SID_LIBRARY_PATH) [join [glob "../../sid/component/*"] ":"]
 	    set env(SID) "../../sid/main/dynamic/sid"
-	    if {! [file exists $env(SID)]} then { error "Cannot find sid in build tree" }
+	    if {![file exists $env(SID)]} { error "Cannot find sid in build tree" }
 	}
 	if { [board_info target sim,protocol] == "sid" } {
 	    set spawncmd "[target_info sim] [target_info sim,options] $sidendian2 -e \"set cpu-gdb-socket sockaddr-local 0.0.0.0:$port\""
@@ -169,7 +169,7 @@  proc gdb_load { arg } {
     global retval
 
     if { $arg != "" } {
-	if [gdb_file_cmd $arg] then { return -1 }
+	if {[gdb_file_cmd $arg]} { return -1 }
     }
 
     gdb_target_sid
@@ -181,25 +181,25 @@  proc gdb_load { arg } {
     verbose "Timeout is now $timeout seconds" 2
     gdb_expect {
 	-re ".*\[Ee\]rror.*$gdb_prompt $" {
-	    if $verbose>1 then {
+	    if {$verbose > 1} {
 		perror "Error during download."
 	    }
 	    set retval -1
 	}
 	-re ".*$gdb_prompt $" {
-	    if $verbose>1 then {
+	    if {$verbose > 1} {
 		send_user "Loaded $arg into $GDB\n"
 	    }
 	    set retval 0
 	}
 	-re "$gdb_prompt $"     {
-	    if $verbose>1 then {
+	    if {$verbose > 1} {
 		perror "GDB couldn't load."
 	    }
 	    set retval -1
 	}
 	timeout {
-	    if $verbose>1 then {
+	    if {$verbose > 1} {
 		perror "Timed out trying to load $arg."
 	    }
 	    set retval -1
diff --git a/gdb/testsuite/config/sim.exp b/gdb/testsuite/config/sim.exp
index 862958510ea..57c54589e80 100644
--- a/gdb/testsuite/config/sim.exp
+++ b/gdb/testsuite/config/sim.exp
@@ -48,26 +48,26 @@  proc gdb_load { arg } {
     global gdb_prompt
 
     if { $arg != "" } {
-	if [gdb_file_cmd $arg] then { return -1 }
+	if {[gdb_file_cmd $arg]} { return -1 }
     }
 
-    if [gdb_target_sim] then { return -1 }
+    if {[gdb_target_sim]} { return -1 }
 
     send_gdb "load\n"
     gdb_expect 2400 {
 	-re ".*$gdb_prompt $" {
-	    if $verbose>1 then {
+	    if {$verbose > 1} {
 		send_user "Loaded $arg into $GDB\n"
 	    }
 	    return 0
 	}
 	-re "$gdb_prompt $"     {
-	    if $verbose>1 then {
+	    if {$verbose > 1} {
 		perror "GDB couldn't load."
 	    }
 	}
 	timeout {
-	    if $verbose>1 then {
+	    if {$verbose > 1} {
 		perror "Timed out trying to load $arg."
 	    }
 	}
diff --git a/gdb/testsuite/config/slite.exp b/gdb/testsuite/config/slite.exp
index 34679a82190..d81aaa29f94 100644
--- a/gdb/testsuite/config/slite.exp
+++ b/gdb/testsuite/config/slite.exp
@@ -83,7 +83,7 @@  proc gdb_load { arg } {
 	}
 	 -re "Remote target.*$gdb_prompt $" { }
 	 -re ".*SPARClite appears to be alive.*$gdb_prompt $"	{
-	    if $verbose>1 then {
+	    if {$verbose > 1} {
 		send_user "Set target to $targetname\n"
 	    }
 	}
@@ -119,12 +119,12 @@  proc gdb_load { arg } {
 		verbose "Timeout is now $timeout seconds" 2
 	    }
 	     -re "$gdb_prompt $"     {
-		if $verbose>1 then {
+		if {$verbose > 1} {
 		    perror "GDB couldn't load."
 		}
 	    }
 	     timeout {
-		if $verbose>1 then {
+		if {$verbose > 1} {
 		    perror "Timed out trying to load $arg."
 		}
 	    }
@@ -172,7 +172,7 @@  proc gdb_load { arg } {
 	}
     }
 
-    if [info exists expect_out(buffer)] then {
+    if {[info exists expect_out(buffer)]} {
 	send_log $expect_out(buffer)
     }
     return 0
diff --git a/gdb/testsuite/lib/cp-support.exp b/gdb/testsuite/lib/cp-support.exp
index 87bbf9104a1..82ad59d9905 100644
--- a/gdb/testsuite/lib/cp-support.exp
+++ b/gdb/testsuite/lib/cp-support.exp
@@ -251,7 +251,7 @@  proc cp_test_ptype_class { in_exp in_testname in_key in_tag in_class_table
 	# The test name defaults to the command, but without the
 	# arguments, for historical reasons.
 
-	if { "$in_testname" == "" } then { set in_testname "ptype $in_exp" }
+	if {"$in_testname" == ""} { set in_testname "ptype $in_exp" }
 
 	set in_command "ptype${in_ptype_arg} $in_exp"
     }
@@ -259,8 +259,8 @@  proc cp_test_ptype_class { in_exp in_testname in_key in_tag in_class_table
     # Save class tables in a history array for reuse.
 
     global cp_class_table_history
-    if { $in_class_table == "ibid" } then {
-	if { ! [info exists cp_class_table_history("$in_key,$in_tag") ] } then {
+    if {$in_class_table == "ibid"} {
+	if {![info exists cp_class_table_history("$in_key,$in_tag")]} {
 	    fail "$in_testname // bad ibid"
 	    return false
 	}
@@ -385,7 +385,7 @@  proc cp_test_ptype_class { in_exp in_testname in_key in_tag in_class_table
 
     # Check the actual tag.
 
-    if { "$actual_tag" != "$in_tag" } then {
+    if {"$actual_tag" != "$in_tag"} {
 	cp_check_errata "$in_tag" "$actual_tag" $in_errata_table
 	fail "$in_testname // wrong tag: $actual_tag"
 	return false
@@ -395,18 +395,18 @@  proc cp_test_ptype_class { in_exp in_testname in_key in_tag in_class_table
     # First parse them into a list.
 
     set list_actual_bases { }
-    if { "$actual_base_string" != "" } then {
+    if {"$actual_base_string" != ""} {
 	regsub "^:${wsopt}" $actual_base_string "" actual_base_string
 	set list_actual_bases [split $actual_base_string ","]
     }
 
     # Check the base count.
 
-    if { [llength $list_actual_bases] < [llength $list_bases] } then {
+    if {[llength $list_actual_bases] < [llength $list_bases]} {
 	fail "$in_testname // too few bases"
 	return false
     }
-    if { [llength $list_actual_bases] > [llength $list_bases] } then {
+    if {[llength $list_actual_bases] > [llength $list_bases]} {
 	fail "$in_testname // too many bases"
 	return false
     }
@@ -416,7 +416,7 @@  proc cp_test_ptype_class { in_exp in_testname in_key in_tag in_class_table
     foreach actual_base $list_actual_bases {
 	set actual_base [string trim $actual_base]
 	set base [lindex $list_bases 0]
-	if { "$actual_base" != "$base" } then {
+	if {"$actual_base" != "$base"} {
 	    cp_check_errata "$base" "$actual_base" $in_errata_table
 	    fail "$in_testname // wrong base: $actual_base"
 	    return false
@@ -449,13 +449,13 @@  proc cp_test_ptype_class { in_exp in_testname in_key in_tag in_class_table
 	# Get the next line.
 
 	set actual_line [cp_support_internal::next_line $line_queue]
-	if { "$actual_line" == "" } then { continue }
+	if {"$actual_line" == ""} { continue }
 
 	# Access specifiers.
 
-	if { [regexp "^(public|protected|private)${wsopt}:\$" "$actual_line" s0 s1] } then {
+	if {[regexp "^(public|protected|private)${wsopt}:\$" "$actual_line" s0 s1]} {
 	    set access "$s1"
-	    if { $last_was_access } then {
+	    if {$last_was_access} {
 		fail "$in_testname // redundant access specifier"
 		queue delete $line_queue
 		return false
@@ -468,10 +468,10 @@  proc cp_test_ptype_class { in_exp in_testname in_key in_tag in_class_table
 
 	# Optional virtual base pointer.
 
-	if { [ llength $list_vbases ] > 0 } then {
+	if {[llength $list_vbases] > 0} {
 	    set vbase [lindex $list_vbases 0]
-	    if { [ regexp "$vbase \\*(_vb.|_vb\\\$|__vb_)\[0-9\]*$vbase;" $actual_line ] } then {
-		if { "$access" != "private" } then {
+	    if {[regexp "$vbase \\*(_vb.|_vb\\\$|__vb_)\[0-9\]*$vbase;" $actual_line]} {
+		if {"$access" != "private"} {
 		    cp_check_errata "private" "$access" $in_errata_table
 		    fail "$in_testname // wrong access specifier for virtual base: $access"
 		    queue delete $line_queue
@@ -485,7 +485,7 @@  proc cp_test_ptype_class { in_exp in_testname in_key in_tag in_class_table
 
 	# Data field.
 
-	if { [llength $list_fields] > 0 } then {
+	if {[llength $list_fields] > 0} {
 	    set field_access [lindex [lindex $list_fields 0] 0]
 	    set field_decl   [lindex [lindex $list_fields 0] 1]
 	    if {$recursive_qid > 0} {
@@ -494,8 +494,8 @@  proc cp_test_ptype_class { in_exp in_testname in_key in_tag in_class_table
 		cp_ptype_class_verbose "\tfield_decl=$field_decl"
 		cp_ptype_class_verbose "\taccess=$access"
 	    }
-	    if { "$actual_line" == "$field_decl" } then {
-		if { "$access" != "$field_access" } then {
+	    if {"$actual_line" == "$field_decl"} {
+		if {"$access" != "$field_access"} {
 		    cp_check_errata "$field_access" "$access" $in_errata_table
 		    fail "$in_testname // wrong access specifier for field: $access"
 		    queue delete $line_queue
@@ -514,11 +514,11 @@  proc cp_test_ptype_class { in_exp in_testname in_key in_tag in_class_table
 
 	# Method function.
 
-	if { [llength $list_methods] > 0 } then {
+	if {[llength $list_methods] > 0} {
 	    set method_access [lindex [lindex $list_methods 0] 0]
 	    set method_decl   [lindex [lindex $list_methods 0] 1]
-	    if { "$actual_line" == "$method_decl" } then {
-		if { "$access" != "$method_access" } then {
+	    if {"$actual_line" == "$method_decl"} {
+		if {"$access" != "$method_access"} {
 		    cp_check_errata "$method_access" "$access" $in_errata_table
 		    fail "$in_testname // wrong access specifier for method: $access"
 		    queue delete $line_queue
@@ -530,8 +530,8 @@  proc cp_test_ptype_class { in_exp in_testname in_key in_tag in_class_table
 
 	    # gcc 2.95.3 shows "foo()" as "foo(void)".
 	    regsub -all "\\(\\)" $method_decl "(void)" method_decl
-	    if { "$actual_line" == "$method_decl" } then {
-		if { "$access" != "$method_access" } then {
+	    if {"$actual_line" == "$method_decl"} {
+		if {"$access" != "$method_access"} {
 		    cp_check_errata "$method_access" "$access" $in_errata_table
 		    fail "$in_testname // wrong access specifier for method: $access"
 		    queue delete $line_queue
@@ -689,16 +689,16 @@  proc cp_test_ptype_class { in_exp in_testname in_key in_tag in_class_table
 	    set synth_access  [lindex $synth 1]
 	    set synth_re      [lindex $synth 2]
 
-	    if { [ regexp "$synth_re" "$actual_line" ] } then {
+	    if {[regexp "$synth_re" "$actual_line"]} {
 
-		if { "$access" != "$synth_access" } then {
+		if {"$access" != "$synth_access"} {
 		    cp_check_errata "$synth_access" "$access" $in_errata_table
 		    fail "$in_testname // wrong access specifier for synthetic operator: $access"
 		    queue delete $line_queue
 		    return false
 		}
 
-		if { $synth_count > 0 } then {
+		if {$synth_count > 0} {
 		    cp_check_errata "$actual_line" "$actual_line" $in_errata_table
 		    fail "$in_testname // duplicate synthetic operator: $actual_line"
 		}
@@ -715,7 +715,7 @@  proc cp_test_ptype_class { in_exp in_testname in_key in_tag in_class_table
 		break
 	    }
 	}
-	if { $synth_match } then { continue }
+	if {$synth_match} { continue }
 
 	# If checking a nested type/recursively and we see a closing curly
 	# brace, we're done.
@@ -725,7 +725,7 @@  proc cp_test_ptype_class { in_exp in_testname in_key in_tag in_class_table
 
 	# Unrecognized line.
 
-	if { [llength $list_methods] > 0 } then {
+	if {[llength $list_methods] > 0} {
 	    set method_decl [lindex [lindex $list_methods 0] 1]
 	    cp_check_errata "$method_decl" "$actual_line" $in_errata_table
 	}
@@ -742,19 +742,19 @@  proc cp_test_ptype_class { in_exp in_testname in_key in_tag in_class_table
 
     # Check for missing elements.
 
-    if { $vbase_match } then {
-	if { [llength $list_vbases] > 0 } then {
+    if {$vbase_match} {
+	if {[llength $list_vbases] > 0} {
 	    fail "$in_testname // missing virtual base pointers"
 	    return false
 	}
     }
 
-    if { [llength $list_fields] > 0 } then {
+    if {[llength $list_fields] > 0} {
 	fail "$in_testname // missing fields"
 	return false
     }
 
-    if { [llength $list_methods] > 0 } then {
+    if {[llength $list_methods] > 0} {
 	fail "$in_testname // missing methods"
 	return false
     }
@@ -767,7 +767,7 @@  proc cp_test_ptype_class { in_exp in_testname in_key in_tag in_class_table
     # Check the tail.
 
     set actual_tail [string trim $actual_tail]
-    if { "$actual_tail" != "$in_tail" } then {
+    if {"$actual_tail" != "$in_tail"} {
 	cp_check_errata "$in_tail" "$actual_tail" $in_errata_table
 	fail "$in_testname // wrong tail: $actual_tail"
 	return false
diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp
index 9df8e7f9bdc..35f4e957c58 100644
--- a/gdb/testsuite/lib/dwarf.exp
+++ b/gdb/testsuite/lib/dwarf.exp
@@ -104,7 +104,7 @@  proc build_executable_and_dwo_files { testname executable options args } {
     global subdir
     global srcdir
 
-    if { ! [regexp "^/" "$executable"] } then {
+    if {![regexp "^/" "$executable"]} {
 	set binfile [standard_output_file $executable]
     } else {
 	set binfile $executable
@@ -143,7 +143,7 @@  proc build_executable_and_dwo_files { testname executable options args } {
 	set s [lindex $spec 0]
 	set local_options [lindex $spec 1]
 
-	if { ! [regexp "^/" "$s"] } then {
+	if {![regexp "^/" "$s"]} {
 	    set s "$srcdir/$subdir/$s"
 	}
 
@@ -1685,7 +1685,7 @@  namespace eval Dwarf {
 	    proc base { addr } {
 		variable _debug_ranges_64_bit
 
-		if { $_debug_ranges_64_bit } then {
+		if {$_debug_ranges_64_bit} {
 		    _op .8byte 0xffffffffffffffff "Base Marker"
 		    _op .8byte $addr "Base Address"
 		} else {
@@ -1697,7 +1697,7 @@  namespace eval Dwarf {
 	    proc range { start end } {
 		variable _debug_ranges_64_bit
 
-		if { $_debug_ranges_64_bit } then {
+		if {$_debug_ranges_64_bit} {
 		    _op .8byte $start "Start Address"
 		    _op .8byte $end "End Address"
 		} else {
@@ -1709,7 +1709,7 @@  namespace eval Dwarf {
 	    uplevel $body
 
 	    # End of the sequence.
-	    if { $_debug_ranges_64_bit } then {
+	    if {$_debug_ranges_64_bit} {
 		_op .8byte 0x0 "End of Sequence Marker (Part 1)"
 		_op .8byte 0x0 "End of Sequence Marker (Part 2)"
 	    } else {
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 3e0a46445ca..b3a36d10f9d 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -227,7 +227,7 @@  if ![info exists INTERNAL_GDBFLAGS] {
 # but it's not clear what removing one of them will break.
 # See with_gdb_prompt for more details on prompt handling.
 global gdb_prompt
-if ![info exists gdb_prompt] then {
+if {![info exists gdb_prompt]} {
     set gdb_prompt "\\(gdb\\)"
 }
 
@@ -1135,7 +1135,7 @@  proc gdb_test_multiple { command message args } {
     regsub -all {\r} $patterns {\\r} patterns
     regsub -all {\n} $patterns {\\n} patterns
 
-    if $verbose>2 then {
+    if {$verbose > 2} {
 	send_user "Sending \"$command\" to gdb\n"
 	send_user "Looking to match \"$patterns\"\n"
 	send_user "Message is \"$message\"\n"
@@ -1206,7 +1206,7 @@  proc gdb_test_multiple { command message args } {
 
     append code {
 	-re "Ending remote debugging.*$prompt_regexp" {
-	    if ![isnative] then {
+	    if {![isnative]} {
 		warning "Can`t communicate to remote target."
 	    }
 	    gdb_exit
@@ -1224,7 +1224,7 @@  proc gdb_test_multiple { command message args } {
 	    set result 1
 	}
 	-re "$inferior_exited_re with code \[0-9\]+.*$prompt_regexp" {
-	    if ![string match "" $message] then {
+	    if {![string match "" $message]} {
 		set errmsg "$message (the program exited)"
 	    } else {
 		set errmsg "$command (the program exited)"
@@ -1233,7 +1233,7 @@  proc gdb_test_multiple { command message args } {
 	    set result -1
 	}
 	-re "$inferior_exited_re normally.*$prompt_regexp" {
-	    if ![string match "" $message] then {
+	    if {![string match "" $message]} {
 		set errmsg "$message (the program exited)"
 	    } else {
 		set errmsg "$command (the program exited)"
@@ -1242,7 +1242,7 @@  proc gdb_test_multiple { command message args } {
 	    set result -1
 	}
 	-re "The program is not being run.*$prompt_regexp" {
-	    if ![string match "" $message] then {
+	    if {![string match "" $message]} {
 		set errmsg "$message (the program is no longer running)"
 	    } else {
 		set errmsg "$command (the program is no longer running)"
@@ -1251,7 +1251,7 @@  proc gdb_test_multiple { command message args } {
 	    set result -1
 	}
 	-re "\r\n$prompt_regexp" {
-	    if ![string match "" $message] then {
+	    if {![string match "" $message]} {
 		fail "$message"
 	    }
 	    set result 1
@@ -1311,7 +1311,7 @@  proc gdb_test_multiple { command message args } {
 	    set result -1
 	}
 	timeout	{
-	    if ![string match "" $message] then {
+	    if {![string match "" $message]} {
 		fail "$message (timeout)"
 	    }
 	    set result 1
@@ -1669,13 +1669,13 @@  proc test_print_reject { args } {
     global gdb_prompt
     global verbose
 
-    if [llength $args]==2 then {
+    if {[llength $args] == 2} {
 	set expectthis [lindex $args 1]
     } else {
 	set expectthis "should never match this bogus string"
     }
     set sendthis [lindex $args 0]
-    if $verbose>2 then {
+    if {$verbose > 2} {
 	send_user "Sending \"$sendthis\" to gdb\n"
 	send_user "Looking to match \"$expectthis\"\n"
     }
@@ -1762,7 +1762,7 @@  proc gdb_test_exact { args } {
     # case some users of gdb_test_exact already do the right thing.
     regsub -all "\r\n" $pattern "\n" pattern
     regsub -all "\n" $pattern "\r\n" pattern
-    if [llength $args]==3 then {
+    if {[llength $args] == 3} {
 	set message [lindex $args 2]
 	return [gdb_test $command $pattern $message]
     }
@@ -2240,7 +2240,7 @@  proc default_gdb_spawn { } {
     }
 
     if ![is_remote host] {
-	if { [which $GDB] == 0 } then {
+	if {[which $GDB] == 0} {
 	    perror "$GDB does not exist."
 	    exit 1
 	}
@@ -4587,7 +4587,7 @@  gdb_caching_proc universal_compile_options {
     # such an option is specified.
     set opt "additional_flags=-fdiagnostics-color=never"
     set lines [target_compile $src $obj object [list "quiet" $opt]]
-    if [string match "" $lines] then {
+    if {[string match "" $lines]} {
 	# Seems to have worked; use the option.
 	lappend options $opt
     }
@@ -4638,7 +4638,7 @@  proc gdb_simple_compile {name code {type object} {compile_flags {}} {object obj}
 
     file delete $src
 
-    if ![string match "" $lines] then {
+    if {![string match "" $lines]} {
         verbose "$name:  compilation failed, returning 0" 2
         return 0
     }
@@ -5505,7 +5505,7 @@  proc can_spawn_for_attach { } {
     # We use exp_pid to get the inferior's pid, assuming that gives
     # back the pid of the program.  On remote boards, that would give
     # us instead the PID of e.g., the ssh client, etc.
-    if [is_remote target] then {
+    if {[is_remote target]} {
 	verbose -log "can't spawn for attach (target is remote)"
 	return 0
     }
@@ -6530,7 +6530,7 @@  proc test_debug_format {format} {
 proc setup_xfail_format { format } {
     set ret [test_debug_format $format]
 
-    if {$ret} then {
+    if {$ret} {
 	setup_xfail "*-*-*"
     }
     return $ret
@@ -6604,32 +6604,32 @@  proc gdb_get_line_number { text { file "" } } {
     global subdir
     global srcfile
 
-    if { "$file" == "" } then {
+    if {"$file" == ""} {
 	set file "$srcfile"
     }
-    if { ! [regexp "^/" "$file"] } then {
+    if {![regexp "^/" "$file"]} {
 	set file "$srcdir/$subdir/$file"
     }
 
-    if { [ catch { set fd [open "$file"] } message ] } then {
+    if {[catch { set fd [open "$file"] } message]} {
 	error "$message"
     }
 
     set found -1
     for { set line 1 } { 1 } { incr line } {
-	if { [ catch { set nchar [gets "$fd" body] } message ] } then {
+	if {[catch { set nchar [gets "$fd" body] } message]} {
 	    error "$message"
 	}
-	if { $nchar < 0 } then {
+	if {$nchar < 0} {
 	    break
 	}
-	if { [string first "$text" "$body"] >= 0 } then {
+	if {[string first "$text" "$body"] >= 0} {
 	    set found $line
 	    break
 	}
     }
 
-    if { [ catch { close "$fd" } message ] } then {
+    if {[catch { close "$fd" } message]} {
 	error "$message"
     }
 
@@ -6841,7 +6841,7 @@  gdb_caching_proc gdb_skip_float_test {
 	set lines [gdb_compile $src $exe executable $compile_flags]
 	file delete $src
 
-	if ![string match "" $lines] then {
+	if {![string match "" $lines]} {
 	    verbose "testfile compilation failed, returning 1" 2
 	    return 0
 	}
@@ -7085,7 +7085,7 @@  proc get_build_id { filename } {
 	set data [read $fi]
 	close $fi
 	file delete $tmp
-	if ![string compare $data ""] then {
+	if {![string compare $data ""]} {
 	    return ""
 	}
 	# Convert it to hex.
@@ -7301,7 +7301,7 @@  proc build_executable_from_specs {testname executable options args} {
     if [string match gdb_compile_shlib* $func] {
 	set sources_path {}
 	foreach {s local_options} $args {
-	    if { [regexp "^/" "$s"] } then {
+	    if {[regexp "^/" "$s"]} {
 		lappend sources_path "$s"
 	    } else {
 		lappend sources_path "$srcdir/$subdir/$s"
@@ -7311,7 +7311,7 @@  proc build_executable_from_specs {testname executable options args} {
     } elseif {[lsearch -exact $options rust] != -1} {
 	set sources_path {}
 	foreach {s local_options} $args {
-	    if { [regexp "^/" "$s"] } then {
+	    if {[regexp "^/" "$s"]} {
 		lappend sources_path "$s"
 	    } else {
 		lappend sources_path "$srcdir/$subdir/$s"
@@ -7322,7 +7322,7 @@  proc build_executable_from_specs {testname executable options args} {
 	set objects {}
 	set i 0
 	foreach {s local_options} $args {
-	    if { ! [regexp "^/" "$s"] } then {
+	    if {![regexp "^/" "$s"]} {
 		set s "$srcdir/$subdir/$s"
 	    }
 	    if  { [$func "${s}" "${binfile}${i}.o" object $local_options] != "" } {
@@ -8076,7 +8076,7 @@  proc parse_list { level listname argset prefix eval } {
 	    set pattern "$prefix$argument"
 	    set result [lsearch -exact $args $pattern]
 
-	    if {$result != -1} then {
+	    if {$result != -1} {
 		set value 1
 		set args [lreplace $args $result $result]
 	    } else {
@@ -8092,7 +8092,7 @@  proc parse_list { level listname argset prefix eval } {
 	    set pattern "$prefix[lindex $arg 0]"
 	    set result [lsearch -exact $args $pattern]
 
-	    if {$result != -1} then {
+	    if {$result != -1} {
 		set value [lindex $args [expr $result+1]]
 		if { $eval } {
 		    set value [uplevel [expr $level + 1] [list subst $value]]
@@ -8417,7 +8417,7 @@  proc cmp_file_string { file str msg } {
 	set file_contents [read $fp]
 	close $fp
     } error_message]
-    if { $caught_error } then {
+    if {$caught_error} {
 	error "$error_message"
 	fail "$msg"
 	return
diff --git a/gdb/testsuite/lib/mi-support.exp b/gdb/testsuite/lib/mi-support.exp
index b11457693be..ab81c07f664 100644
--- a/gdb/testsuite/lib/mi-support.exp
+++ b/gdb/testsuite/lib/mi-support.exp
@@ -22,7 +22,7 @@  load_lib gdb-utils.exp
 # The variable mi_gdb_prompt is a regexp which matches the gdb mi prompt.
 # Set it if it is not already set.
 global mi_gdb_prompt
-if ![info exists mi_gdb_prompt] then {
+if {![info exists mi_gdb_prompt]} {
     set mi_gdb_prompt "\[(\]gdb\[)\] \r\n"
 }
 
@@ -727,19 +727,19 @@  proc mi_gdb_test { args } {
     global inferior_exited_re async
     upvar timeout timeout
 
-    if { [llength $args] >= 1 } then {
+    if {[llength $args] >= 1} {
 	set command [lindex $args 0]
     } else {
 	error "Not enough arguments in mi_gdb_test"
     }
 
-    if { [llength $args] >= 2 } then {
+    if {[llength $args] >= 2} {
 	set pattern [lindex $args 1]
     } else {
 	set pattern ".*"
     }
 
-    if { [llength $args] >= 3 } then {
+    if {[llength $args] >= 3} {
 	set message [lindex $args 2]
     } else {
 	set message $command
@@ -760,7 +760,7 @@  proc mi_gdb_test { args } {
 	error "Too many arguments in mi_gdb_test"
     }
 
-    if $verbose>2 then {
+    if {$verbose > 2} {
 	send_user "Sending \"$command\" to gdb\n"
 	send_user "Looking to match \"$pattern\"\n"
 	send_user "Message is \"$message\"\n"
@@ -819,7 +819,7 @@  proc mi_gdb_test { args } {
 	     return -1
 	 }
 	 -re "Ending remote debugging.*$mi_gdb_prompt\[ \]*$" {
-	    if ![isnative] then {
+	    if {![isnative]} {
 		warning "Can`t communicate to remote target."
 	    }
 	    gdb_exit
@@ -839,7 +839,7 @@  proc mi_gdb_test { args } {
 	    # match a single mi output command.  If a second GDB/MI output 
 	    # response is sent, it will be in the buffer for the next 
 	    # time mi_gdb_test is called.
-	    if ![string match "" $message] then {
+	    if {![string match "" $message]} {
 		pass "$message"
 	    }
 	    set result 0
@@ -859,7 +859,7 @@  proc mi_gdb_test { args } {
 	    set result 1
 	}
 	 -re "$inferior_exited_re with code \[0-9\]+.*$mi_gdb_prompt\[ \]*$" {
-	    if ![string match "" $message] then {
+	    if {![string match "" $message]} {
 		set errmsg "$message (the program exited)"
 	    } else {
 		set errmsg "$command (the program exited)"
@@ -868,7 +868,7 @@  proc mi_gdb_test { args } {
 	    return -1
 	}
 	 -re "The program is not being run.*$mi_gdb_prompt\[ \]*$" {
-	    if ![string match "" $message] then {
+	    if {![string match "" $message]} {
 		set errmsg "$message (the program is no longer running)"
 	    } else {
 		set errmsg "$command (the program is no longer running)"
@@ -877,7 +877,7 @@  proc mi_gdb_test { args } {
 	    return -1
 	}
 	 -re ".*$mi_gdb_prompt\[ \]*$" {
-	    if ![string match "" $message] then {
+	    if {![string match "" $message]} {
 		fail "$message (unexpected output)"
 	    }
 	    set result 1
@@ -899,7 +899,7 @@  proc mi_gdb_test { args } {
 	     fail "$message"
 	}
 	timeout	{
-	    if ![string match "" $message] then {
+	    if {![string match "" $message]} {
 		fail "$message (timeout)"
 	    }
 	    set result 1
@@ -1742,7 +1742,7 @@  proc mi_prepare_inline_tests { filename } {
 
     set mi_autotest_source $filename
 
-    if { ! [regexp "^/" "$filename"] } then {
+    if {![regexp "^/" "$filename"]} {
 	set filename "$srcdir/$subdir/$filename"
     }
 
diff --git a/gdb/testsuite/lib/prompt.exp b/gdb/testsuite/lib/prompt.exp
index d648130b611..1bd34ab72d2 100644
--- a/gdb/testsuite/lib/prompt.exp
+++ b/gdb/testsuite/lib/prompt.exp
@@ -38,7 +38,7 @@  proc default_prompt_gdb_start { } {
     }
 
     if ![is_remote host] {
-	if { [which $GDB] == 0 } then {
+	if {[which $GDB] == 0} {
 	    perror "$GDB does not exist."
 	    exit 1
 	}
diff --git a/gdb/testsuite/lib/selftest-support.exp b/gdb/testsuite/lib/selftest-support.exp
index 2b17c539a96..3c270d88527 100644
--- a/gdb/testsuite/lib/selftest-support.exp
+++ b/gdb/testsuite/lib/selftest-support.exp
@@ -21,12 +21,12 @@  proc find_gdb { arg } {
     # If the arg directly specifies an existing executable file, then
     # simply use it.
 
-    if [file executable $arg] then {
+    if {[file executable $arg]} {
 	return $arg
     }
 
     set result [which $arg]
-    if [string match "/" [ string range $result 0 0 ]] then {
+    if {[string match "/" [ string range $result 0 0 ]]} {
 	return $result
     }
 
@@ -54,11 +54,11 @@  proc selftest_setup { executable function } {
 
     set result [gdb_load $executable]
 
-    if { $result != 0 } then {
+    if {$result != 0} {
 	return -1
     }
 
-    if { $gdb_file_cmd_debug_info != "debug" } then {
+    if {$gdb_file_cmd_debug_info != "debug"} {
 	untested "no debug information, skipping testcase."
 	return -2
     }
@@ -139,7 +139,7 @@  proc do_self_tests {function body} {
     # duration of the test.
     with_timeout_factor 10 {
 	set result [selftest_setup $file $function]
-	if {$result == 0} then {
+	if {$result == 0} {
 	    set result [uplevel $body]
 	}
     }
@@ -147,7 +147,7 @@  proc do_self_tests {function body} {
     gdb_exit
     catch "remote_file host delete $file"
 
-    if {$result == -1} then {
+    if {$result == -1} {
 	warning "Couldn't test self"
     }
 }
diff --git a/gdb/testsuite/lib/trace-support.exp b/gdb/testsuite/lib/trace-support.exp
index ccad22ecd99..49bf9bd9653 100644
--- a/gdb/testsuite/lib/trace-support.exp
+++ b/gdb/testsuite/lib/trace-support.exp
@@ -208,7 +208,7 @@  proc gdb_trace_setactions_command { actions_command testname tracepoint args } {
     if { $testname != "" } {
 	$passfail $testname
     }
-    if { $passfail == "pass" } then { 
+    if {$passfail == "pass"} {
 	return 0
     } else {
 	return 1
@@ -265,7 +265,7 @@  proc gdb_tfind_test { testname tfind_arg exp_res args } {
 	-re "$gdb_prompt $" { }
     }
     $passfail "$testname"
-    if { $passfail == "pass" } then { 
+    if {$passfail == "pass"} {
 	return 0
     } else {
 	return 1
@@ -395,7 +395,7 @@  proc generate_tracefile { binfile } {
 
 	clean_restart $binfile
 
-	if ![runto_main] then {
+	if {![runto_main]} {
 	    return 0
 	}
 	gdb_continue_to_end "" continue 1