@@ -61,8 +61,8 @@ fn default_entry_file(f: &mut fat::File) -> Result<[u8; 260], fat::Error> {
61
61
62
62
let conf = unsafe { core:: str:: from_utf8_unchecked ( & data) } ;
63
63
for line in conf. lines ( ) {
64
- if line. starts_with ( "default" ) {
65
- let entry = line [ "default" . len ( ) .. ] . trim ( ) ;
64
+ if let Some ( entry ) = line. strip_prefix ( "default" ) {
65
+ let entry = entry . trim ( ) ;
66
66
entry_file_name[ 0 ..entry. len ( ) ] . copy_from_slice ( entry. as_bytes ( ) ) ;
67
67
}
68
68
}
@@ -89,16 +89,16 @@ fn parse_entry(f: &mut fat::File) -> Result<LoaderConfig, fat::Error> {
89
89
90
90
let conf = unsafe { core:: str:: from_utf8_unchecked ( & data) } ;
91
91
for line in conf. lines ( ) {
92
- if line. starts_with ( "linux" ) {
93
- let entry = line [ "linux" . len ( ) .. ] . trim ( ) ;
92
+ if let Some ( entry ) = line. strip_prefix ( "linux" ) {
93
+ let entry = entry . trim ( ) ;
94
94
loader_config. bzimage_path [ 0 ..entry. len ( ) ] . copy_from_slice ( entry. as_bytes ( ) ) ;
95
95
}
96
- if line. starts_with ( "options" ) {
97
- let entry = line [ "options" . len ( ) .. ] . trim ( ) ;
96
+ if let Some ( entry ) = line. strip_prefix ( "options" ) {
97
+ let entry = entry . trim ( ) ;
98
98
loader_config. cmdline [ 0 ..entry. len ( ) ] . copy_from_slice ( entry. as_bytes ( ) ) ;
99
99
}
100
- if line. starts_with ( "initrd" ) {
101
- let entry = line [ "initrd" . len ( ) .. ] . trim ( ) ;
100
+ if let Some ( entry ) = line. strip_prefix ( "initrd" ) {
101
+ let entry = entry . trim ( ) ;
102
102
loader_config. initrd_path [ 0 ..entry. len ( ) ] . copy_from_slice ( entry. as_bytes ( ) ) ;
103
103
}
104
104
}
0 commit comments