From d68196969d17fa74a1347fca7a940b1e9e9da287 Mon Sep 17 00:00:00 2001 From: Pedro Pereira Date: Tue, 23 Nov 2021 10:40:23 +0000 Subject: [PATCH] Pong: Port to LibMain Simplified two pledge() and two unveil() by using TRY(). --- Userland/Games/Pong/CMakeLists.txt | 2 +- Userland/Games/Pong/main.cpp | 28 ++++++++-------------------- 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/Userland/Games/Pong/CMakeLists.txt b/Userland/Games/Pong/CMakeLists.txt index 20638e587cc..d6f8de6dc1b 100644 --- a/Userland/Games/Pong/CMakeLists.txt +++ b/Userland/Games/Pong/CMakeLists.txt @@ -10,4 +10,4 @@ set(SOURCES ) serenity_app(Pong ICON app-pong) -target_link_libraries(Pong LibGUI) +target_link_libraries(Pong LibGUI LibMain) diff --git a/Userland/Games/Pong/main.cpp b/Userland/Games/Pong/main.cpp index a3c27290b16..2d0c9acd8e3 100644 --- a/Userland/Games/Pong/main.cpp +++ b/Userland/Games/Pong/main.cpp @@ -5,37 +5,25 @@ */ #include "Game.h" +#include #include #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(Core::System::pledge("stdio rpath recvfd sendfd unix", nullptr)); - auto app = GUI::Application::construct(argc, argv); + auto app = GUI::Application::construct(arguments); - if (pledge("stdio rpath recvfd sendfd", nullptr) < 0) { - perror("pledge"); - return 1; - } + TRY(Core::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(Core::System::unveil("/res", "r")); + TRY(Core::System::unveil(nullptr, nullptr)); auto window = GUI::Window::construct(); window->resize(Pong::Game::game_width, Pong::Game::game_height);