From 74a6fb64b2cd3bcfe98d9e31642385baea70bff7 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 29 Nov 2021 21:35:04 +0100 Subject: [PATCH] DHCPClient: Port to LibMain :^) --- Userland/Services/DHCPClient/CMakeLists.txt | 2 +- Userland/Services/DHCPClient/main.cpp | 31 ++++++--------------- 2 files changed, 9 insertions(+), 24 deletions(-) diff --git a/Userland/Services/DHCPClient/CMakeLists.txt b/Userland/Services/DHCPClient/CMakeLists.txt index 30d3dd70d2..c6f8b729f0 100644 --- a/Userland/Services/DHCPClient/CMakeLists.txt +++ b/Userland/Services/DHCPClient/CMakeLists.txt @@ -11,4 +11,4 @@ set(SOURCES ) serenity_bin(DHCPClient) -target_link_libraries(DHCPClient LibCore) +target_link_libraries(DHCPClient LibCore LibMain) diff --git a/Userland/Services/DHCPClient/main.cpp b/Userland/Services/DHCPClient/main.cpp index 70055f8c14..812ab78275 100644 --- a/Userland/Services/DHCPClient/main.cpp +++ b/Userland/Services/DHCPClient/main.cpp @@ -5,35 +5,20 @@ */ #include "DHCPv4Client.h" -#include -#include #include -#include -#include -#include +#include +#include -int main([[maybe_unused]] int argc, [[maybe_unused]] char** argv) +ErrorOr serenity_main(Main::Arguments) { - if (pledge("stdio unix inet cpath rpath", nullptr) < 0) { - perror("pledge"); - return 1; - } - + TRY(Core::System::pledge("stdio unix inet cpath rpath")); Core::EventLoop event_loop; - if (unveil("/proc/net/", "r") < 0) { - perror("unveil"); - return 1; - } + TRY(Core::System::unveil("/proc/net/", "r")); + TRY(Core::System::unveil(nullptr, nullptr)); - unveil(nullptr, nullptr); - - auto client = DHCPv4Client::construct(); - - if (pledge("stdio inet cpath rpath", nullptr) < 0) { - perror("pledge"); - return 1; - } + auto client = TRY(DHCPv4Client::try_create()); + TRY(Core::System::pledge("stdio inet cpath rpath")); return event_loop.exec(); }