@@ -132,7 +132,7 @@ Result<void> RepackVendorRamdisk(const std::string& kernel_modules_ramdisk_path,
132132 const std::string& new_ramdisk_path,
133133 const std::string& build_dir) {
134134 const std::string ramdisk_stage_dir = build_dir + " /" + TMP_RD_DIR;
135- UnpackRamdisk (original_ramdisk_path, ramdisk_stage_dir);
135+ CF_EXPECT ( UnpackRamdisk (original_ramdisk_path, ramdisk_stage_dir) );
136136
137137 int success = Execute ({" rm" , " -rf" , ramdisk_stage_dir + " /lib/modules" });
138138 CF_EXPECT_EQ (success, 0 , " Could not rmdir 'lib/modules' in TMP_RD_DIR. " );
@@ -169,17 +169,18 @@ Result<void> PackRamdisk(const std::string& ramdisk_stage_dir,
169169 return {};
170170}
171171
172- void UnpackRamdisk (const std::string& original_ramdisk_path,
173- const std::string& ramdisk_stage_dir) {
172+ Result< void > UnpackRamdisk (const std::string& original_ramdisk_path,
173+ const std::string& ramdisk_stage_dir) {
174174 int success = 0 ;
175175 if (IsCpioArchive (original_ramdisk_path)) {
176- CHECK (Copy (original_ramdisk_path, original_ramdisk_path + kCpioExt ))
177- << " failed to copy " << original_ramdisk_path << " to "
178- << original_ramdisk_path + kCpioExt ;
176+ CF_EXPECTF (Copy (original_ramdisk_path, original_ramdisk_path + kCpioExt ),
177+ " Failed to copy '{}' to '{}' " , original_ramdisk_path,
178+ original_ramdisk_path + kCpioExt ) ;
179179 } else {
180180 SharedFD output_fd = SharedFD::Open (original_ramdisk_path + kCpioExt ,
181181 O_CREAT | O_RDWR | O_TRUNC, 0644 );
182- CHECK (output_fd->IsOpen ()) << output_fd->StrError ();
182+ CF_EXPECTF (output_fd->IsOpen (), " Failed to open '{}': '{}'" ,
183+ original_ramdisk_path + kCpioExt , output_fd->StrError ());
183184
184185 success = Command (HostBinaryPath (" lz4" ))
185186 .AddParameter (" -c" )
@@ -189,11 +190,11 @@ void UnpackRamdisk(const std::string& original_ramdisk_path,
189190 .RedirectStdIO (Subprocess::StdIOChannel::kStdOut , output_fd)
190191 .Start ()
191192 .Wait ();
192- CHECK_EQ (success, 0 ) << " Unable to run lz4 on file '"
193- << original_ramdisk_path << " '." ;
193+ CF_EXPECT_EQ (
194+ success, 0 ,
195+ " Unable to run lz4 on file '" << original_ramdisk_path << " '." );
194196 }
195- const auto ret = EnsureDirectoryExists (ramdisk_stage_dir);
196- CHECK (ret.ok ()) << ret.error ();
197+ CF_EXPECT (EnsureDirectoryExists (ramdisk_stage_dir));
197198
198199 SharedFD input = SharedFD::Open (original_ramdisk_path + kCpioExt , O_RDONLY);
199200 int cpio_status;
@@ -206,6 +207,7 @@ void UnpackRamdisk(const std::string& original_ramdisk_path,
206207 .Start ()
207208 .Wait ();
208209 } while (cpio_status == 0 );
210+ return {};
209211}
210212
211213Result<void > UnpackBootImage (const std::string& boot_image_path,
0 commit comments