Check for existence of config dict fields before using them in generated drivers

This commit is contained in:
Douglas Clowes
2014-06-30 12:49:22 +10:00
parent 62f1170a6d
commit 202004766a
18 changed files with 198 additions and 36 deletions

View File

@@ -1400,12 +1400,21 @@ def put_read_config(MyDriver):
txt += [' set ns "%s"' % MyDriver['namespace']]
txt += [' dict for {k v} $::config_dict {']
txt += [' if { [dict exists $v "implementation"] } {']
txt += [' if { !([dict exists $v "name"] && [dict exists $v "enabled"]) } {']
txt += [' continue']
txt += [' }']
txt += [' set name [dict get $v name]']
txt += [' set enabled [string tolower [dict get $v "enabled"]]']
txt += [' set implementation [dict get $v "implementation"]']
txt += [' if { !([dict exists $::config_dict $implementation]) } {']
txt += [' continue']
txt += [' }']
txt += [' set v [dict get $::config_dict $implementation]']
txt += [' if { [dict get $v "driver"] == "%s" } {' % MyDriver['name']]
txt += [' if { [dict get $v enabled] } {']
txt += [' if { !([dict exists $v "driver"]) } {']
txt += [' continue']
txt += [' }']
txt += [' if { [string equal -nocase [dict get $v "driver"] "%s"] } {' % MyDriver['name']]
txt += [' if { [string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"] } {']
txt += [' if { ![string equal -nocase [SplitReply [%s]] "false"] } {' % MyDriver['simulation_group']]
txt += [' set asyncqueue "null"']
txt += [' ${ns}::sics_log 9 "[%s] => using null asyncqueue"' % MyDriver['simulation_group']]