From ddd99b45943a02602e30f07581bb07f8764c84eb Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 23 Nov 2021 15:28:41 +0100 Subject: [PATCH] NotificationServer: Port to LibMain :^) --- .../NotificationServer/CMakeLists.txt | 2 +- Userland/Services/NotificationServer/main.cpp | 30 +++++++------------ 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/Userland/Services/NotificationServer/CMakeLists.txt b/Userland/Services/NotificationServer/CMakeLists.txt index fc59c4d4e0..e76c52dcb7 100644 --- a/Userland/Services/NotificationServer/CMakeLists.txt +++ b/Userland/Services/NotificationServer/CMakeLists.txt @@ -16,4 +16,4 @@ set(SOURCES ) serenity_bin(NotificationServer) -target_link_libraries(NotificationServer LibGUI LibIPC) +target_link_libraries(NotificationServer LibGUI LibIPC LibMain) diff --git a/Userland/Services/NotificationServer/main.cpp b/Userland/Services/NotificationServer/main.cpp index 059c631c2b..210b2c0ce0 100644 --- a/Userland/Services/NotificationServer/main.cpp +++ b/Userland/Services/NotificationServer/main.cpp @@ -1,24 +1,22 @@ /* - * Copyright (c) 2020, Andreas Kling + * Copyright (c) 2020-2021, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #include "ClientConnection.h" #include +#include #include #include -#include +#include -int main(int argc, char** argv) +ErrorOr serenity_main(Main::Arguments arguments) { - if (pledge("stdio recvfd sendfd accept rpath unix", nullptr) < 0) { - perror("pledge"); - return 1; - } + TRY(Core::System::pledge("stdio recvfd sendfd accept rpath unix", nullptr)); - auto app = GUI::Application::construct(argc, argv); - auto server = Core::LocalServer::construct(); + auto app = TRY(GUI::Application::try_create(arguments)); + auto server = TRY(Core::LocalServer::try_create()); bool ok = server->take_over_from_system_server(); VERIFY(ok); @@ -33,17 +31,9 @@ int main(int argc, char** argv) IPC::new_client_connection(client_socket.release_nonnull(), client_id); }; - if (unveil("/res", "r") < 0) { - perror("unveil"); - return 1; - } - - unveil(nullptr, nullptr); - - if (pledge("stdio recvfd sendfd accept rpath", nullptr) < 0) { - perror("pledge"); - return 1; - } + TRY(Core::System::unveil("/res", "r")); + TRY(Core::System::unveil(nullptr, nullptr)); + TRY(Core::System::pledge("stdio recvfd sendfd accept rpath", nullptr)); return app->exec(); }