File tree Expand file tree Collapse file tree 1 file changed +4
-8
lines changed Expand file tree Collapse file tree 1 file changed +4
-8
lines changed Original file line number Diff line number Diff line change @@ -61,8 +61,7 @@ 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" ) {
66
65
entry_file_name[ 0 ..entry. len ( ) ] . copy_from_slice ( entry. as_bytes ( ) ) ;
67
66
}
68
67
}
@@ -89,16 +88,13 @@ fn parse_entry(f: &mut fat::File) -> Result<LoaderConfig, fat::Error> {
89
88
90
89
let conf = unsafe { core:: str:: from_utf8_unchecked ( & data) } ;
91
90
for line in conf. lines ( ) {
92
- if line. starts_with ( "linux" ) {
93
- let entry = line[ "linux" . len ( ) ..] . trim ( ) ;
91
+ if let Some ( entry) = line. strip_prefix ( "linux" ) {
94
92
loader_config. bzimage_path [ 0 ..entry. len ( ) ] . copy_from_slice ( entry. as_bytes ( ) ) ;
95
93
}
96
- if line. starts_with ( "options" ) {
97
- let entry = line[ "options" . len ( ) ..] . trim ( ) ;
94
+ if let Some ( entry) = line. strip_prefix ( "options" ) {
98
95
loader_config. cmdline [ 0 ..entry. len ( ) ] . copy_from_slice ( entry. as_bytes ( ) ) ;
99
96
}
100
- if line. starts_with ( "initrd" ) {
101
- let entry = line[ "initrd" . len ( ) ..] . trim ( ) ;
97
+ if let Some ( entry) = line. strip_prefix ( "initrd" ) {
102
98
loader_config. initrd_path [ 0 ..entry. len ( ) ] . copy_from_slice ( entry. as_bytes ( ) ) ;
103
99
}
104
100
}
You can’t perform that action at this time.
0 commit comments