@@ -21,8 +21,8 @@ use crate::sel4::{
2121} ;
2222use crate :: util:: { ranges_overlap, str_to_bool} ;
2323use crate :: MAX_PDS ;
24- use std:: collections:: HashSet ;
2524use std:: collections:: HashMap ;
25+ use std:: collections:: HashSet ;
2626use std:: fmt:: Display ;
2727use std:: path:: { Path , PathBuf } ;
2828
@@ -608,16 +608,16 @@ impl ProtectionDomain {
608608 ( Some ( domain_schedule) , Ok ( domain_name) ) => {
609609 let domain_id_get = domain_schedule. domain_ids . get ( domain_name) ;
610610 if domain_id_get. is_none ( ) {
611- return Err ( format ! ( "Protection domain {} specifies a domain {} that is not in the domain schedule" , name , domain_name ) ) ;
611+ return Err ( format ! ( "Protection domain {name } specifies a domain {domain_name } that is not in the domain schedule" ) ) ;
612612 }
613613 domain_id = Some ( * domain_id_get. unwrap ( ) ) ;
614614 }
615615 ( Some ( _) , _) => {
616- return Err ( format ! ( "System specifies a domain schedule but protection domain {} does not specify a domain" , name ) )
616+ return Err ( format ! ( "System specifies a domain schedule but protection domain {name } does not specify a domain" ) )
617617 }
618618 ( _, Ok ( domain) ) => {
619619 if config. num_domain_schedules > 1 {
620- return Err ( format ! ( "Protection domain {} specifies a domain {} but system does not specify a domain schedule" , name , domain ) ) ;
620+ return Err ( format ! ( "Protection domain {name } specifies a domain {domain } but system does not specify a domain schedule" ) ) ;
621621 } else {
622622 return Err ( "Assigning PDs to domains is only supported built with a config that supports domains" . to_string ( ) ) ;
623623 }
@@ -1029,7 +1029,8 @@ impl ProtectionDomain {
10291029 checked_add_setvar ( & mut setvars, setvar, xml_sdf, & child) ?;
10301030 }
10311031 "protection_domain" => {
1032- let child_pd = ProtectionDomain :: from_xml ( config, xml_sdf, & child, true , domain_schedule) ?;
1032+ let child_pd =
1033+ ProtectionDomain :: from_xml ( config, xml_sdf, & child, true , domain_schedule) ?;
10331034
10341035 if let Some ( setvar_id) = & child_pd. setvar_id {
10351036 let setvar = SysSetVar {
@@ -1127,9 +1128,7 @@ impl DomainSchedule {
11271128 node : & roxmltree:: Node ,
11281129 ) -> Result < DomainSchedule , String > {
11291130 if config. num_domains <= 1 {
1130- return Err ( format ! (
1131- "Error: Attempting to set a domain schedule when kernel config does not support more than 1 domain" ,
1132- ) ) ;
1131+ return Err ( "Error: Attempting to set a domain schedule when kernel config does not support more than 1 domain" . to_string ( ) ) ;
11331132 }
11341133
11351134 let pos = xml_sdf. doc . text_pos_at ( node. range ( ) . start ) ;
@@ -1188,34 +1187,28 @@ impl DomainSchedule {
11881187 return Err ( format ! (
11891188 "Error: Duplicate setting of domain start index, already set to '{}'" ,
11901189 domain_start_idx. unwrap( )
1191- ) )
1190+ ) ) ;
11921191 }
11931192 check_attributes ( xml_sdf, & child, & [ "index" ] ) ?;
11941193 let start_index = checked_lookup ( xml_sdf, & child, "index" ) ?. parse :: < u64 > ( ) ;
11951194 if start_index. is_err ( ) {
1196- return Err ( format ! (
1197- "Error: invalid domain start index" ,
1198- ) )
1195+ return Err ( "Error: invalid domain start index" . to_string ( ) ) ;
11991196 }
12001197 domain_start_idx = Some ( start_index. unwrap ( ) ) ;
1201-
12021198 }
12031199 "domain_idx_shift" => {
12041200 if domain_idx_shift. is_some ( ) {
12051201 return Err ( format ! (
12061202 "Error: Duplicate setting of domain index shift, already set to '{}'" ,
12071203 domain_idx_shift. unwrap( )
1208- ) )
1204+ ) ) ;
12091205 }
12101206 check_attributes ( xml_sdf, & child, & [ "shift" ] ) ?;
12111207 let index_shift = checked_lookup ( xml_sdf, & child, "shift" ) ?. parse :: < u64 > ( ) ;
12121208 if index_shift. is_err ( ) {
1213- return Err ( format ! (
1214- "Error: invalid domain index shift" ,
1215- ) )
1209+ return Err ( "Error: invalid domain index shift" . to_string ( ) ) ;
12161210 }
12171211 domain_idx_shift = Some ( index_shift. unwrap ( ) ) ;
1218-
12191212 }
12201213 _ => {
12211214 return Err ( format ! (
@@ -1224,7 +1217,6 @@ impl DomainSchedule {
12241217 loc_string( xml_sdf, pos)
12251218 ) ) ;
12261219 }
1227-
12281220 }
12291221 }
12301222
@@ -1808,9 +1800,13 @@ pub fn parse(filename: &str, xml: &str, config: &Config) -> Result<SystemDescrip
18081800
18091801 let child_name = child. tag_name ( ) . name ( ) ;
18101802 match child_name {
1811- "protection_domain" => {
1812- root_pds. push ( ProtectionDomain :: from_xml ( config, & xml_sdf, & child, false , & domain_schedule) ?)
1813- }
1803+ "protection_domain" => root_pds. push ( ProtectionDomain :: from_xml (
1804+ config,
1805+ & xml_sdf,
1806+ & child,
1807+ false ,
1808+ & domain_schedule,
1809+ ) ?) ,
18141810 "channel" => channel_nodes. push ( child) ,
18151811 "memory_region" => mrs. push ( SysMemoryRegion :: from_xml ( config, & xml_sdf, & child) ?) ,
18161812 "virtual_machine" => {
@@ -1819,15 +1815,19 @@ pub fn parse(filename: &str, xml: &str, config: &Config) -> Result<SystemDescrip
18191815 "Error: virtual machine must be a child of a protection domain: {}" ,
18201816 loc_string( & xml_sdf, pos)
18211817 ) ) ;
1822- } ,
1818+ }
18231819 "domain_schedule" => {
18241820 if config. num_domain_schedules > 1 {
18251821 if let Some ( domain_schedule_node) = system
18261822 . children ( )
18271823 . filter ( |& child| child. is_element ( ) )
18281824 . find ( |& child| child. tag_name ( ) . name ( ) == "domain_schedule" )
18291825 {
1830- domain_schedule = Some ( DomainSchedule :: from_xml ( & xml_sdf, & config, & domain_schedule_node) ?) ;
1826+ domain_schedule = Some ( DomainSchedule :: from_xml (
1827+ & xml_sdf,
1828+ config,
1829+ & domain_schedule_node,
1830+ ) ?) ;
18311831 }
18321832 }
18331833 }
@@ -2200,18 +2200,16 @@ pub fn parse(filename: &str, xml: &str, config: &Config) -> Result<SystemDescrip
22002200 "Error: Domain index of '{}' is out of bounds for domain schedule length '{}'. Note that the schedule is 0 indexed." ,
22012201 dom_sched. domain_start_idx. unwrap( ) ,
22022202 schedule_len
2203- ) )
2203+ ) ) ;
22042204 }
22052205
22062206 // Make sure our schedule length, including the shift, is in bounds of
22072207 // the kernel configured max number of schedules.
22082208 if schedule_len + dom_shift >= config. num_domain_schedules {
22092209 return Err ( format ! (
22102210 "Error: Schedule length '{}' with shift of '{}' exceeds max schedule length '{}'." ,
2211- schedule_len,
2212- dom_shift,
2213- config. num_domain_schedules,
2214- ) )
2211+ schedule_len, dom_shift, config. num_domain_schedules,
2212+ ) ) ;
22152213 }
22162214 }
22172215
0 commit comments