From a0c80a6f17ce4e4e45e667a2b824931b9845ff9f Mon Sep 17 00:00:00 2001 From: Pedro Pereira Date: Mon, 22 Nov 2021 20:22:12 +0000 Subject: [PATCH] Minesweeper: Port to LibMain Simplified two unveil() and two pledge() by using TRY(). --- Userland/Games/Minesweeper/CMakeLists.txt | 2 +- Userland/Games/Minesweeper/main.cpp | 28 +++++++---------------- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/Userland/Games/Minesweeper/CMakeLists.txt b/Userland/Games/Minesweeper/CMakeLists.txt index fc74b7124b..8118226563 100644 --- a/Userland/Games/Minesweeper/CMakeLists.txt +++ b/Userland/Games/Minesweeper/CMakeLists.txt @@ -14,4 +14,4 @@ set(SOURCES ) serenity_app(Minesweeper ICON app-minesweeper) -target_link_libraries(Minesweeper LibGUI LibConfig) +target_link_libraries(Minesweeper LibGUI LibConfig LibMain) diff --git a/Userland/Games/Minesweeper/main.cpp b/Userland/Games/Minesweeper/main.cpp index d8b8237357..3bbdbec59e 100644 --- a/Userland/Games/Minesweeper/main.cpp +++ b/Userland/Games/Minesweeper/main.cpp @@ -18,34 +18,22 @@ #include #include #include +#include +#include #include -#include -int main(int argc, char** argv) +ErrorOr serenity_main(Main::Arguments arguments) { - if (pledge("stdio rpath recvfd sendfd unix", nullptr) < 0) { - perror("pledge"); - return 1; - } + TRY(System::pledge("stdio rpath recvfd sendfd unix", nullptr)); - auto app = GUI::Application::construct(argc, argv); + auto app = GUI::Application::construct(arguments.argc, arguments.argv); Config::pledge_domains("Minesweeper"); - if (pledge("stdio rpath recvfd sendfd", nullptr) < 0) { - perror("pledge"); - return 1; - } + TRY(System::pledge("stdio rpath recvfd sendfd", nullptr)); - if (unveil("/res", "r") < 0) { - perror("unveil"); - return 1; - } - - if (unveil(nullptr, nullptr) < 0) { - perror("unveil"); - return 1; - } + TRY(System::unveil("/res", "r")); + TRY(System::unveil(nullptr, nullptr)); auto app_icon = GUI::Icon::default_icon("app-minesweeper");