diff options
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Utilities/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Userland/Utilities/fdtdump.cpp | 19 |
2 files changed, 7 insertions, 14 deletions
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 <AK/String.h> #include <LibCore/ArgsParser.h> #include <LibCore/MappedFile.h> +#include <LibCore/System.h> #include <LibDeviceTree/Validation.h> -#include <serenity.h> +#include <LibMain/Main.h> -int main(int argc, char* argv[]) +ErrorOr<int> 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); |