From 85e283265453b698f1f5a22b2eeedc0c05aafe91 Mon Sep 17 00:00:00 2001 From: Ben Elliston Date: Tue, 29 Mar 2016 10:52:29 +1100 Subject: More fixes identified by the Frink static analyser: (1) use -- in switch commands for safety, (2) add braces around exprs, (3) replace abbreviated "info proc" with "info procs", (4) use -- in regexp commands for safety where the expression is a variable that could begin with '-'. --- config/adb.exp | 8 ++++---- config/vxworks.exp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'config') diff --git a/config/adb.exp b/config/adb.exp index b5e5d6c..4326fa4 100644 --- a/config/adb.exp +++ b/config/adb.exp @@ -43,13 +43,13 @@ proc adb_open { hostname } { set tries 0 set result -1 - if [board_info ${hostname} exists shell_prompt] { + if {[board_info ${hostname} exists shell_prompt]} { set shell_prompt [board_info ${hostname} shell_prompt] } else { set shell_prompt "root@android:/ # " } - if [board_info $hostname exists fileid] { + if {[board_info $hostname exists fileid]} { unset board_info($hostname,fileid) } @@ -116,7 +116,7 @@ proc adb_download {desthost srcfile destfile} { proc adb_file {dest op args} { set file [lindex $args 0] verbose "Executing command: $op $args" 2 - switch $op { + switch -- $op { exists { set status [catch "exec adb [adb_serial] shell ls |& cat" out] } @@ -185,5 +185,5 @@ proc adb_exec { boardname cmd args } { # Delete one trailing \n because that is what `exec' will do and we want # to behave identical to it. regsub "\n$" $output "" output - return [list [expr $status != 0] $output] + return [list [expr {$status != 0}] $output] } diff --git a/config/vxworks.exp b/config/vxworks.exp index 05f8810..f93ea3b 100644 --- a/config/vxworks.exp +++ b/config/vxworks.exp @@ -179,7 +179,7 @@ proc vxworks_file { dest op args } { set file [lindex $args 0] if {[board_info $dest exists vxworks_homedir]} { set dir "[board_info $dest vxworks_homedir]" - switch $op { + switch -- $op { exists { set file "${dir}/[file tail $file]" return [file exists $file] @@ -191,7 +191,7 @@ proc vxworks_file { dest op args } { file delete -force -- $x } } - return + return {} } } } -- cgit v1.1