11use std:: {
2- ffi:: OsString ,
2+ ffi:: OsStr ,
33 fs,
44 path:: { Path , PathBuf } ,
55 process:: Command ,
@@ -607,7 +607,7 @@ fn generate_pcrlock_files(
607607 ) ;
608608 } ;
609609
610- let pcrlock_file = generate_pcrlock_output_path ( & OsString :: from ( sub_dir) , index) ;
610+ let pcrlock_file = generate_pcrlock_output_path ( sub_dir, index) ;
611611 debug ! (
612612 "Generating .pcrlock file at '{}' to measure bootloader PE binary at '{}'" ,
613613 pcrlock_file. display( ) ,
@@ -634,10 +634,8 @@ fn generate_pcrlock_files(
634634 // measured into PCR 4 as well.
635635 if !efivar:: secure_boot_is_enabled ( ) {
636636 for ( index, uki_path) in uki_binaries. into_iter ( ) . enumerate ( ) {
637- let pcrlock_file = generate_pcrlock_output_path (
638- & OsString :: from ( BOOT_LOADER_CODE_UKI_PCRLOCK_DIR ) ,
639- index,
640- ) ;
637+ let pcrlock_file =
638+ generate_pcrlock_output_path ( BOOT_LOADER_CODE_UKI_PCRLOCK_DIR , index) ;
641639 debug ! (
642640 "SecureBoot is disabled, so generating .pcrlock file at '{}' \
643641 to measure .linux section of UKI PE binary at '{}'",
@@ -724,7 +722,7 @@ where
724722 G : FnMut ( PathBuf , PathBuf ) -> Result < ( ) , Error > ,
725723{
726724 // Generate .pcrlock file for the UKI binary, which covers both PCR 4 and PCR 11 measurements for that UKI binary
727- let pcrlock_file = generate_pcrlock_output_path ( & OsString :: from ( UKI_PCRLOCK_DIR ) , index) ;
725+ let pcrlock_file = generate_pcrlock_output_path ( UKI_PCRLOCK_DIR , index) ;
728726 lock_uki ( uki_path. clone ( ) , pcrlock_file. clone ( ) ) ?;
729727
730728 // Check the UKI addon path (`uki_path` + 'extra.d') for existence, and if it exists, generate a .pcrlock file for it as well,
@@ -796,9 +794,10 @@ where
796794/// Generates a full .pcrlock file path under PCRLOCK_DIR, given the sub-dir, and the index of the
797795/// .pcrlock file. This is needed so that each image, current and update, gets its own .pcrlock
798796/// file.
799- fn generate_pcrlock_output_path ( pcrlock_subdir : & OsString , index : usize ) -> PathBuf {
800- let base = Path :: new ( PCRLOCK_DIR ) . join ( pcrlock_subdir) ;
801- base. join ( format ! ( "generated-{index}.pcrlock" ) )
797+ fn generate_pcrlock_output_path ( pcrlock_subdir : impl AsRef < OsStr > , index : usize ) -> PathBuf {
798+ Path :: new ( PCRLOCK_DIR )
799+ . join ( pcrlock_subdir. as_ref ( ) )
800+ . join ( format ! ( "generated-{index}.pcrlock" ) )
802801}
803802
804803/// Generates .pcrlock file to record measurement of the `.linux` section of the UKI binary,
@@ -869,7 +868,7 @@ mod tests {
869868 . join ( BOOT_LOADER_CODE_SHIM_PCRLOCK_DIR )
870869 . join ( format ! ( "generated-{index}.pcrlock" ) ) ;
871870 assert_eq ! (
872- generate_pcrlock_output_path( & OsString :: from ( BOOT_LOADER_CODE_SHIM_PCRLOCK_DIR ) , index) ,
871+ generate_pcrlock_output_path( BOOT_LOADER_CODE_SHIM_PCRLOCK_DIR , index) ,
873872 expected_path
874873 ) ;
875874 }
@@ -955,10 +954,10 @@ mod tests {
955954 "lock_pe should be called with the correct addon path"
956955 ) ;
957956 let expected_pcrlock_path = generate_pcrlock_output_path (
958- & OsString :: from ( format ! (
957+ format ! (
959958 "{}test_addon{}" ,
960959 UKI_ADDONS_PCRLOCK_DIR_PREFIX , UKI_ADDONS_PCRLOCK_DIR_SUFFIX
961- ) ) ,
960+ ) ,
962961 index,
963962 ) ;
964963 assert_eq ! (
0 commit comments