From 27e63d40f1cb2615353d25c4f0a7dc3563ebef22 Mon Sep 17 00:00:00 2001 From: Kenneth Myhra Date: Tue, 7 Dec 2021 22:06:38 +0100 Subject: fdtdump: Port to LibMain --- Userland/Utilities/CMakeLists.txt | 2 +- Userland/Utilities/fdtdump.cpp | 19 ++++++------------- 2 files changed, 7 insertions(+), 14 deletions(-) (limited to 'Userland') diff --git a/Userland/Utilities/CMakeLists.txt b/Userland/Utilities/CMakeLists.txt index e3be7ec899..be0c1e21ce 100644 --- a/Userland/Utilities/CMakeLists.txt +++ b/Userland/Utilities/CMakeLists.txt @@ -87,7 +87,7 @@ target_link_libraries(disasm LibX86) target_link_libraries(dmesg LibMain) target_link_libraries(echo LibMain) target_link_libraries(expr LibRegex) -target_link_libraries(fdtdump LibDeviceTree) +target_link_libraries(fdtdump LibDeviceTree LibMain) target_link_libraries(file LibGfx LibIPC LibCompress) target_link_libraries(find LibMain) target_link_libraries(fortune LibMain) diff --git a/Userland/Utilities/fdtdump.cpp b/Userland/Utilities/fdtdump.cpp index d5f22cbdf9..4c812110a8 100644 --- a/Userland/Utilities/fdtdump.cpp +++ b/Userland/Utilities/fdtdump.cpp @@ -7,29 +7,22 @@ #include #include #include +#include #include -#include +#include -int main(int argc, char* argv[]) +ErrorOr serenity_main(Main::Arguments arguments) { - if (pledge("stdio rpath", nullptr) < 0) { - perror("pledge"); - return 1; - } + TRY(Core::System::pledge("stdio rpath")); String filename; Core::ArgsParser args; args.add_positional_argument(filename, "File to process", "file", Core::ArgsParser::Required::Yes); - args.parse(argc, argv); + args.parse(arguments); // FIXME: Figure out how to do this sanely from stdin - auto maybe_file = Core::MappedFile::map(filename); - if (maybe_file.is_error()) { - warnln("Unable to dump device tree from file {}: {}", filename, maybe_file.error()); - return 1; - } - auto file = maybe_file.release_value(); + auto file = TRY(Core::MappedFile::map(filename)); if (file->size() < sizeof(DeviceTree::FlattenedDeviceTreeHeader)) { warnln("Not enough data in {} to contain a device tree header!", filename); -- cgit v1.2.3