Skip to content

Commit 7ca4031

Browse files
committed
fixed some nagelfar tcl linter syntax warnings.
1 parent 805fb55 commit 7ca4031

File tree

7 files changed

+21
-32
lines changed

7 files changed

+21
-32
lines changed

xmlapi/common.tcl

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ loadOnce tclrpc.so
1414

1515
proc decr {x {cnt 1}} {
1616
upvar $x xx
17-
set xx [expr $xx - $cnt]
17+
set xx [expr { $xx - $cnt }]
1818
}
1919
proc max {x y} { expr { $x > $y ? $x : $y } }
2020
proc min {x y} { expr { $x > $y ? $y : $x } }
2121

2222
proc cgi_cgi {args} {return $args}
2323

24-
proc in {list element} {expr [lsearch -exact $list $element] >= 0}
24+
proc in {list element} {expr { [lsearch -exact $list $element] >= 0 } }
2525

2626
proc array_clear {name} {
2727
upvar $name arr
@@ -30,13 +30,6 @@ proc array_clear {name} {
3030
}
3131
}
3232

33-
proc array_copy {src_name dst_name} {
34-
35-
global $src_name $dst_name
36-
array_clear $dst_name
37-
array set $dst_name [array get $src_name]
38-
}
39-
4033
#Liest eine Datei ein mit dem Format
4134
#Key=Value
4235
#Key=Value
@@ -118,13 +111,6 @@ proc eval_script {script} {
118111
return $ret
119112
}
120113

121-
proc BitsSet {b_testee b_set} {
122-
123-
if {$b_testee == "" || $b_set == "" || $b_testee == 0 || $b_set == 0} then { return 0 }
124-
125-
return [expr [expr $b_set & $b_testee] == $b_testee]
126-
}
127-
128114
proc putimage {img_path} {
129115

130116
set in [open $img_path]
@@ -161,7 +147,7 @@ array set interface_descriptions ""
161147
proc read_interfaces {} {
162148
global interfaces interface_descriptions INTERFACES_FILE env
163149
set retval 1
164-
if { [ info exist env(BIDCOS_SERVICE) ] } {
150+
if { [ info exists env(BIDCOS_SERVICE) ] } {
165151
set interfaces(default) "$env(BIDCOS_SERVICE)"
166152
set interface_descriptions(default) "Default BidCoS Interface"
167153
} else {
@@ -171,7 +157,7 @@ proc read_interfaces {} {
171157
set contents [read $fd]
172158
while { [regexp -indices {</ipc[^>]*>} $contents range] } {
173159
set section [string range $contents 0 [lindex $range 1]]
174-
set contents [string range $contents [expr [lindex $range 1] + 1] end]
160+
set contents [string range $contents [expr { [lindex $range 1] + 1 }] end]
175161
if {
176162
[regexp {<name[^>]*>([^<]+)</name} $section dummy name] &&
177163
[regexp {<url[^>]*>([^<]+)</url} $section dummy url] &&

xmlapi/devicelist.cgi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ if {[info exists sid] && [check_session $sid]} {
165165
Write("</device>");
166166
}
167167
}
168-
}]
168+
}]
169169

170170
if { $res(STDOUT) != "" } {
171171
puts -nonewline $res(STDOUT)

xmlapi/exec.cgi

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ if {[info exists sid] && [check_session $sid]} {
3535
set first 1
3636
set result "\{\n"
3737
foreach name [array names script_result] {
38-
if { 1 != $first } { append result ",\n" } { set first 0 }
38+
if { 1 != $first } {
39+
append result ",\n"
40+
}
41+
set first 0
3942
set value $script_result($name)
4043
append result " [toString $name]: [toString $value]"
4144
}

xmlapi/scripterrors.cgi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ if {[info exists sid] && [check_session $sid]} {
1111

1212
set Datei [open "|/usr/bin/tail -n 10 /var/log/messages" r]
1313
while {[gets $Datei Zeile] >= 0} {
14-
if [regexp Error.*near $Zeile] {
14+
if { [regexp Error.*near $Zeile] } {
1515
regexp {([a-zA-Z]+ [0-9]+ [0-9\:]+) .+ local0.err ReGaHss: ERROR: SyntaxError\: Error ([0-9]+) at row ([0-9]+) col ([0-9]+)} $Zeile line time code row col
1616
puts -nonewline "<error "
1717
puts -nonewline "timestamp='$time' "

xmlapi/session.tcl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ proc save_tokens tokenlist {
3636
}
3737
}
3838

39-
proc register_token desc {
39+
proc register_token descr {
4040
# get tokens
4141
array set tokens [get_tokens]
4242

@@ -45,21 +45,21 @@ proc register_token desc {
4545
set newToken [subst [string repeat {[format %c [expr {int(rand() * 26) + (rand() > .5 ? 97 : 65)}]]} 16]]
4646

4747
# add token to array
48-
set tokens($newToken) $desc
48+
set tokens($newToken) $descr
4949

5050
# save tokens
5151
save_tokens [array get tokens]
5252

5353
return $newToken
5454
}
5555

56-
proc revoke_token token {
56+
proc revoke_token tid {
5757
# get tokens
5858
array set tokens [get_tokens]
5959

60-
if {[info exists tokens($token)]} {
60+
if {[info exists tokens($tid)]} {
6161
# remove token from array
62-
unset tokens($token)
62+
unset tokens($tid)
6363

6464
# write out new token list
6565
save_tokens [array get tokens]
@@ -69,19 +69,19 @@ proc revoke_token token {
6969
return 0
7070
}
7171

72-
proc check_session sid {
72+
proc check_session session_id {
7373
global raddr
7474
# check for api tokens first and then check
7575
# for webui session ids as well as a fallback
76-
if {[regexp {^([0-9a-zA-Z]{16})$} $sid all sidnr]} {
76+
if {[regexp {^([0-9a-zA-Z]{16})$} $session_id all sidnr]} {
7777
# get tokens
7878
array set tokens [get_tokens]
7979

8080
# check if sid exists in token array
81-
if {[info exists tokens($sid)]} {
81+
if {[info exists tokens($session_id)]} {
8282
return 1
8383
}
84-
} elseif {[regexp {^@([0-9a-zA-Z]{10})@$} $sid all sidnr]} {
84+
} elseif {[regexp {^@([0-9a-zA-Z]{10})@$} $session_id all sidnr]} {
8585
set res [lindex [rega_script "Write(system.GetSessionVarStr('$sidnr'));"] 1]
8686
if {$res != ""} {
8787
return 1

xmlapi/statechange.cgi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ if {[info exists sid] && [check_session $sid]} {
2828
regsub -all {%21} $new_value {!} new_value
2929
regsub -all {%23} $new_value {#} new_value
3030
regsub -all {%25} $new_value {%} new_value
31-
regsub -all {%2A} $new_value {*} new_value
31+
regsub -all {%2A} $new_value * new_value
3232
regsub -all {%2F} $new_value {/} new_value
3333
regsub -all {%3C} $new_value {<} new_value
3434
regsub -all {%3E} $new_value {>} new_value

xmlapi/statelist.cgi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ if {[info exists sid] && [check_session $sid]} {
5656
Write(" timestamp='");WriteXML(oDP.Timestamp().ToInteger());Write("'");
5757
Write(" />");
5858
}
59-
}
59+
}
6060

6161
} else {
6262

0 commit comments

Comments
 (0)