mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 01:20:25 +00:00
LibArchive: Simplify error handling
This commit is contained in:
parent
0f1f925532
commit
ee0c9ed87b
Notes:
sideshowbarker
2024-07-17 16:42:19 +09:00
Author: https://github.com/implicitfield Commit: https://github.com/SerenityOS/serenity/commit/ee0c9ed87b Pull-request: https://github.com/SerenityOS/serenity/pull/16122 Reviewed-by: https://github.com/petelliott ✅
4 changed files with 5 additions and 20 deletions
|
@ -34,8 +34,7 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* data, size_t size)
|
|||
return 0;
|
||||
}
|
||||
|
||||
auto maybe_error = tar_stream.advance();
|
||||
if (maybe_error.is_error())
|
||||
if (tar_stream.advance().is_error())
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -104,11 +104,7 @@ ErrorOr<void> TarInputStream::advance()
|
|||
|
||||
m_generation++;
|
||||
|
||||
auto header_size_or_error = m_header.size();
|
||||
if (header_size_or_error.is_error())
|
||||
return header_size_or_error.release_error();
|
||||
auto header_size = header_size_or_error.release_value();
|
||||
|
||||
auto header_size = TRY(m_header.size());
|
||||
VERIFY(m_stream.discard_or_error(block_ceiling(header_size) - m_file_offset));
|
||||
m_file_offset = 0;
|
||||
|
||||
|
|
|
@ -75,11 +75,7 @@ inline ErrorOr<void> TarInputStream::for_each_extended_header(F func)
|
|||
|
||||
Archive::TarFileStream file_stream = file_contents();
|
||||
|
||||
auto header_size_or_error = header().size();
|
||||
if (header_size_or_error.is_error())
|
||||
return header_size_or_error.release_error();
|
||||
auto header_size = header_size_or_error.release_value();
|
||||
|
||||
auto header_size = TRY(header().size());
|
||||
ByteBuffer file_contents_buffer = TRY(ByteBuffer::create_zeroed(header_size));
|
||||
VERIFY(file_stream.read(file_contents_buffer) == header_size);
|
||||
|
||||
|
|
|
@ -159,11 +159,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
if (extract) {
|
||||
String absolute_path = Core::File::absolute_path(filename);
|
||||
auto parent_path = LexicalPath(absolute_path).parent();
|
||||
|
||||
auto header_mode_or_error = header.mode();
|
||||
if (header_mode_or_error.is_error())
|
||||
return header_mode_or_error.release_error();
|
||||
auto header_mode = header_mode_or_error.release_value();
|
||||
auto header_mode = TRY(header.mode());
|
||||
|
||||
switch (header.type_flag()) {
|
||||
case Archive::TarFileType::NormalFile:
|
||||
|
@ -204,9 +200,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
// Non-global headers should be cleared after every file.
|
||||
local_overrides.clear();
|
||||
|
||||
auto maybe_error = tar_stream.advance();
|
||||
if (maybe_error.is_error())
|
||||
return maybe_error.error();
|
||||
TRY(tar_stream.advance());
|
||||
}
|
||||
file_stream.close();
|
||||
|
||||
|
|
Loading…
Reference in a new issue