@@ -61,8 +61,8 @@ fn default_entry_file(f: &mut fat::File) -> Result<[u8; 260], fat::Error> {
6161
6262 let conf = unsafe { core:: str:: from_utf8_unchecked ( & data) } ;
6363 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 ( ) ;
6666 entry_file_name[ 0 ..entry. len ( ) ] . copy_from_slice ( entry. as_bytes ( ) ) ;
6767 }
6868 }
@@ -89,16 +89,16 @@ fn parse_entry(f: &mut fat::File) -> Result<LoaderConfig, fat::Error> {
8989
9090 let conf = unsafe { core:: str:: from_utf8_unchecked ( & data) } ;
9191 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 ( ) ;
9494 loader_config. bzimage_path [ 0 ..entry. len ( ) ] . copy_from_slice ( entry. as_bytes ( ) ) ;
9595 }
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 ( ) ;
9898 loader_config. cmdline [ 0 ..entry. len ( ) ] . copy_from_slice ( entry. as_bytes ( ) ) ;
9999 }
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 ( ) ;
102102 loader_config. initrd_path [ 0 ..entry. len ( ) ] . copy_from_slice ( entry. as_bytes ( ) ) ;
103103 }
104104 }
0 commit comments