summaryrefslogtreecommitdiff
path: root/Userland/Utilities
diff options
context:
space:
mode:
authorAndrew Kaster <akaster@serenityos.org>2023-02-17 10:25:55 -0700
committerLinus Groh <mail@linusgroh.de>2023-02-19 13:49:07 +0100
commit895f54f4873198c057b5189c29aba4009d5e1031 (patch)
treea5d114c2903210f17bbfec6ba8d8d3928d9ff750 /Userland/Utilities
parent01f32a22b4734c3934904b78072c55f2b134ade0 (diff)
downloadserenity-895f54f4873198c057b5189c29aba4009d5e1031.zip
LibDeviceTree: Refactor dump() to return ErrorOr, and use ReadonlyBytes
ReadonlyBytes is much nicer to use than a u8 const* + size_t.
Diffstat (limited to 'Userland/Utilities')
-rw-r--r--Userland/Utilities/fdtdump.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/Userland/Utilities/fdtdump.cpp b/Userland/Utilities/fdtdump.cpp
index b6e6841c18..46ab0e3094 100644
--- a/Userland/Utilities/fdtdump.cpp
+++ b/Userland/Utilities/fdtdump.cpp
@@ -29,9 +29,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
return 1;
}
- auto* fdt_header = reinterpret_cast<DeviceTree::FlattenedDeviceTreeHeader const*>(file->data());
+ auto const* fdt_header = reinterpret_cast<DeviceTree::FlattenedDeviceTreeHeader const*>(file->data());
+ auto bytes = ReadonlyBytes { file->data(), file->size() };
- bool valid = DeviceTree::dump(*fdt_header, static_cast<u8 const*>(file->data()), file->size());
+ TRY(DeviceTree::dump(*fdt_header, bytes));
- return valid ? 0 : 1;
+ return 0;
}